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)