473,386 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

What function in JScript like VBScript's Int() function

Hello,
in vbscript:
Int(11.4)=11

What function in JScript like this function?
Thank you

Jul 19 '05 #1
5 8873
"W. Jack" wrote in message news:uD*************@tk2msftngp13.phx.gbl...
: Hello,
: in vbscript:
: Int(11.4)=11
:
: What function in JScript like this function?

parseInt(11.4)

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 19 '05 #2
Roland Hall wrote on 13 mei 2004 in
microsoft.public.inetserver.asp.general:
"W. Jack" wrote in message news:uD*************@tk2msftngp13.phx.gbl...
: Hello,
: in vbscript:
: Int(11.4)=11
:
: What function in JScript like this function?

parseInt(11.4)


should be:

parseInt( '11.4', 10)

But I prefer Math.floor()

parseInt() acts nearly like Fix()
Math.floor() more like Int()

===========================

tested on IE6:

<script>
// javascript test, no type spec, sorry puritans

alert(parseInt( 11.4 ) ) // 11
alert(parseInt( -11.4 ) ) // -11
//alert(parseInt( 011.4 ) ) // error !!!!!
alert(parseInt( '011.4' ) ) // 9 octal !!!!
alert(parseInt( '-011.4', 10) ) // -11

alert(Math.floor( 11.4) ) // 11
//alert(Math.floor( 011.4) ) // error
alert(Math.floor( '011.4') ) // 11
alert(Math.floor( '-011.4') ) // -12

</script>

<script language=vbs>
// vbscript test, outdated type spec, sorry puritans
// alert is accepted as is the // instead of '

alert(Int( 11.4 ) ) ' 11
alert(Int( -11.4 ) ) ' -12
alert(Int( -011.4 ) ) ' -12

alert(Fix( 11.4 ) ) ' 11
alert(Fix( -11.4 ) ) ' -11

</script>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #3
Thank you very much

Jul 19 '05 #4
Thank you very much

Jul 19 '05 #5
"Evertjan." wrote in message news:Xn********************@194.109.133.29...
: Roland Hall wrote on 13 mei 2004 in
: microsoft.public.inetserver.asp.general:
:
: > "W. Jack" wrote in message news:uD*************@tk2msftngp13.phx.gbl...
: >: Hello,
: >: in vbscript:
: >: Int(11.4)=11
: >:
: >: What function in JScript like this function?
: >
: > parseInt(11.4)
: >
:
: should be:
:
: parseInt( '11.4', 10)

It said the radix was optional but prefix 0x would be seen as hex and prefix
0 octal, all others decimal.
It [docs] also said it wants a string but didn't complain when I passed a
float. Go figure.

: But I prefer Math.floor()
:
: parseInt() acts nearly like Fix()
: Math.floor() more like Int()

Ya', the signed numbers make the difference.

function parseit(x) {
var a = parseInt(x);
WScript.Echo(a);
}
parseit(11.4);
parseit(-11.4);

Results: 11, -11

function floorit(x) {
var a = Math.floor(x);
WScript.Echo(a);
}
floorit(11.4);
floorit(-11.4);

Results: 11, -12

WScript.Echo(Int(11.4))
WScript.Echo(Int(-11.4))

Results: 11, -12
Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Harag | last post by:
Hi All. I'm stating out doing some web developing. I was wondering which of the server side languages should I concentrate on and learn. I Know CSS, HTML, T-SQL I can look at the client...
4
by: Harag | last post by:
Hi All I currently thinking of converting from my little knowledge of VBscript to jScript ASP. With this in mind I'm looking at my current code to see how it will convert over to Jscript. ...
15
by: Laser Lu | last post by:
In ASP and CGI, which one would be executed more fast and has the better execution efficiency in IIS? And how about writing CGI in VB? -- Best regards, Laser Lu
3
by: Christopher Brandsdal | last post by:
Hi! Maby this is wring newsgroup.. I'm using ASP / VBscript on my own cms system, but I needed to use some jscript to make something work... I'm new to jscript, so here is a simple question:...
10
by: Christopher Brandsdal | last post by:
I have this string: /sites/binaer/demo/fil/Winnie-the-Pooh 1024x768.jpg If I wanted to cut everything before Winnie-the-Pooh 1024x768.jpg, how would I do this? In VBScript I could find the...
26
by: Roland Hall | last post by:
I'm tired of getting beat up on this issue so I thought I'd ask what you some of you think. I know the basic difference between a subroutine and a function is a subroutine performs a task and a...
26
by: Lasse Edsvik | last post by:
Hello I'm trying to build a simple COM+ app in vs.net using C# and i cant register it in component manager..... what more is needed than this: using System; using...
5
by: Maxwell2006 | last post by:
Hi, I have a requirement to develop an application component using only Server-Side Jscript (not Jscript.NET). What is Server-Side Jscript?
7
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - What is JScript? ----------------------------------------------------------------------- JScript is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.