tracker issue : CF-4044533

select a category, or use search below
(searches all categories and all time range)
Title:

Deprecate `int` in favour of `floor`

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): John Whish / John Whish (John Whish)

Created: 08/27/2015

Components: Language

Versions: 11.0

Failure Type: Enhancement Request

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Minor / Unknown

Locale/System: English / Mac 10.9 64 bit

Vote Count: 8

Listed in the version 2016.0.0.297996 Issues Fixed doc
Verification notes: verified_fixed on August 22, 2019 using build 2016.0.01.298513
Suggested language improvement: 

The `int` function implies by it's name that it returns the integer part of a decimal. It would be better to rename it as `floor` which is common in other languages. For example:

<cfscript>
n = 37.3;
writeDump([
    int(n), // 37
    int(0-n), // -38
    fix(n), // 37
    fix(0-n), // -37
    round(n), // 37
    round(0-n)  // -37
]);
</cfscript> 

In this example you can see that `int(-37.3)` returns -38. If the function was called floor in would be much clearer what the intent of the function is. As we already have ceiling this seems like a sensible move.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4044533

External Customer Info:
External Company:  
External Customer Name: John Whish
External Customer Email:

Attachments:

Comments:

Since I encountered this issue today it gets my vote. +1
Vote by External U.
6101 | August 27, 2015 06:30:32 AM GMT
See http://blog.adamcameron.me/2015/08/cfml-how-should-int-behave.html. CFML just gets this wrong.
Vote by External U.
6102 | August 27, 2015 07:10:50 AM GMT
I agree #int( 99.99 )#% with this.
Vote by External U.
6103 | August 27, 2015 07:24:52 AM GMT
Agree +1.....................................................
Vote by External U.
6104 | August 27, 2015 09:06:43 AM GMT
+1 - floor() makes more sense
Vote by External U.
6105 | August 27, 2015 06:51:12 PM GMT
+1 ............................................
Vote by External U.
6106 | August 28, 2015 04:13:08 AM GMT
Yup. +1 - - - - - - - - - - - - - - - - - - - - - -
Vote by External U.
6107 | August 28, 2015 12:32:16 PM GMT
Added the Floor() function which acts the same as Int() function. Int() is not removed for backward compatibility.
Comment by Nikhil S.
6099 | October 20, 2015 03:44:09 AM GMT
@Nikhil, the ticket doesn't call for the *removal* of int(). It calls for its deprecation. Those are two separate things.
Comment by External U.
6100 | December 08, 2015 02:58:39 AM GMT
Hi Adobe, I've verified this is fixed in CF2016 Update 1 (build 2016.0.01.298513). Thanks!, -Aaron
Comment by Aaron N.
31148 | August 22, 2019 09:27:47 AM GMT