Interestingly VBScript and JavaScript both do this in different ways...

[Courtesy of www.devguru.com]

VBScript:

"The Int function converts a decimal number (floating-point) to an integer
number (fix-point).
 
There is one major difference between Int and Fix. Int rounds negative
numbers down. Fix rounds negative numbers up."

JavaScript:

"The top-level function, parseInt, finds the first integer in a string."


So int(-4.9) return -5 in VBScript, whereas parseInt(-4.9) return -4 in
JavaScript.


We could sit here all night and argue about which way is "right". To me,
both make sense (in their own ways), it would seem that the difference of
opinion arises because of the ambiguity of the function name itself - if it
was called nearestInt() or integerPart() (or whatever) then nobody would
have any question about what was being returned. The "logical" thing to do
would be to deprecate int() and replace it with two functions which take the
two different approaches discussed; of course that's not going to happen
because of the amount of existing code that would then break, so the
practical thing to do is, as Sean suggests, RTFM, and if you don't agree
with the way int() works, use a different function (or roll your own to
replace it).

-- 
Andy


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to