Fix/Int (Floor) function oddity in ColdFusion 8

I’ve discovered an odd little “bug” in the Fix and Int functions in ColdFusion 8. The Fix/Int functions work similarly to the Floor function in other languages:

According to the ColdFusion 8 LiveDocs

Int - Calculates the closest integer that is smaller than number. For example, it returns 3 for Int(3.3) and for Int(3.7); it returns -4 for Int(-3.3) and for Int(-3.7)

Fix – Converts a real number to an integer. If number is greater than or equal to 0, the closest integer less than or equal to number. If number is less than 0, the closest integer greater than or equal to number.

Now, if you do #Fix(15)# or #Int(15)# the functions return the correct value of 15. However if you do #Fix((6.84/45.60) * 100)# or #Int((6.84/45.60) * 100)# the functions return 14 which is incorrect since the equation equates to 15.

Bug or Feature?

Share this post:
  • Print
  • email
  • Facebook
  • Twitter
  • Tumblr
  • del.icio.us
  • Digg
  • Reddit
  • Sphinn

Related Posts

This entry was posted in ColdFusion, Programming and tagged , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.
blog comments powered by Disqus
  • Subscribe to my feed Subscriber via Email Follow Me on Twitter! Check me out on Facebook! Check me out on LinkedIn!