473,223 Members | 1,677 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,223 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 8863
"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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.