Yo. Yes indeed, I am really very surprised that there is a precedent out there to do the "round down" method with int()-type functions. Prior to this thread, it would never have occurred to me that anyone would do it any way *other* that "simply return the integer part of the number". Hence me so vociferously suggesting CF was wrong (~ dammit! ;-)
We learn something every day. If nothing else, this got me to dust of my dodgy C skills, and my even dodgier (if that's possible) Java skills and test out what they do in equivalent situations. Both simply chop the number @ the decimal point, like I would have expected them to. I dunno if that's part of the ANSI C spec (cue: Sean), or even if the freebie compiler I D/Led claims to be ANSI compliant. I can't be arsed installing PHP, but the docs reckon it truncates. But - yeah - there's no cut and dried way of doing it, so I guess in future I should not take things for granted and... RTFM. Adam -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Andy Neale Sent: Tuesday, 26 October 2004 10:54 a.m. To: [EMAIL PROTECTED] Subject: RE: [CFCDev] Calling CFC method as URL always returns WDDX? 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] ---------------------------------------------------------- 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]
