473,800 Members | 2,304 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8893
"W. Jack" wrote in message news:uD******** *****@tk2msftng p13.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.publi c.inetserver.as p.general:
"W. Jack" wrote in message news:uD******** *****@tk2msftng p13.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.floo r( 11.4) ) // 11
//alert(Math.floo r( 011.4) ) // error
alert(Math.floo r( '011.4') ) // 11
alert(Math.floo r( '-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******** ************@19 4.109.133.29...
: Roland Hall wrote on 13 mei 2004 in
: microsoft.publi c.inetserver.as p.general:
:
: > "W. Jack" wrote in message news:uD******** *****@tk2msftng p13.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(In t(11.4))
WScript.Echo(In t(-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
5976
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 javascript code and work out what it does but I can't really write it from scratch.
4
5865
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. One thing I have spotted that I can't think of a way round is the ADO recordset.GetRows command.
15
5467
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
2248
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: (1) I want to count how many characters there is in a string. In ASP I just use <%=Len(Variabel)%> How do I do this in Jscript?
10
2059
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 first "/" from the back of the sentence, and cut everything before that, but I'm not shore how to do this in JScript...
26
10817
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 function performs a task and returns a value. The Call keyword is required when using parens with subs with more than 1 parameters. Parens around values passed are ByVal vs ByRef and is a waste of processing if passed ByRef for no reason. I...
26
4501
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 System.EnterpriseServices;
5
1476
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
1435
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - What is JScript? ----------------------------------------------------------------------- JScript is Microsoft's implementation of ECMAScript. Questions that are specific to Microsoft's JScript may also be appropriately asked at: microsoft.public.scripting.jscript
0
9690
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10253
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10033
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5471
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.