tracker issue : CF-4199995

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

DollarFormat NumberFormat Rounding Bug

| View in Tracker

Status/Resolution/Reason: To Test//Fixed

Reporter/Name(from Bugbase): Lynda Stark / Lynda Stark ()

Created: 10/10/2017

Components: Functions

Versions: 2016,2018

Failure Type: Others

Found In Build/Fixed In Build: latest /

Priority/Frequency: Normal / All users will encounter

Locale/System: / Win 2008 Server R2 64 bit

Vote Count: 2

Problem Description:
DollarFormat(1214.225) is returning $1,214.22.  I would expect $1,214.23. DollarFormat(1214.2251) does return $1,214.23.
Steps to Reproduce:
<cfoutput>#DollarFormat(1214.225)#</cfoutput>
Actual Result:
DollarFormat(1214.225) is returning $1,214.22.  I would expect $1,214.23. DollarFormat(1214.2251) does return $1,214.23.
Expected Result:
DollarFormat(1214.225) should return $1,214.23.  
Any Workarounds:

Attachments:

Comments:

@lstark same behaviour observed in other engines like Java, Lucee.
Comment by Dattanand M.
242 | November 08, 2017 05:10:46 AM GMT
Here is another case which returns incorrect results: dollarFormat("6.5850") returns $6.58, yet dollarFormat("6.585") returns $6.59 https://trycf.com/gist/5f911215b32e475085cdc0c73c224c0b/acf11 With respect to the comment about other engines having the same problem, Lucee 4.5 has the problem but Lucee 5 does not.
Vote by Peter F.
29261 | July 09, 2018 06:25:26 PM GMT
Here is another case which returns incorrect results: dollarFormat("6.5850") returns $6.58, yet dollarFormat("6.585") returns $6.59 https://trycf.com/gist/5f911215b32e475085cdc0c73c224c0b/acf11 With respect to the comment about other engines having the same problem, Lucee 4.5 has the problem but Lucee 5 does not.
Comment by Peter F.
29258 | July 09, 2018 06:25:50 PM GMT
I do not see the same problem with numberFormat, so I'm not sure why the title has that in there. But I do see this rounding bug in CF10, CF11, CF2016 and public beta of CF2018.
Comment by Peter F.
29259 | July 09, 2018 06:35:52 PM GMT
I have to retract that comment about numberFormat not have issues... numberFormat(0.05 * 21.9500 * 6, "_.__) gives you 6.58, yet numberFormat("6.585", "_.__) gives you 6.59 - it is broken in the opposite way as dollarFormat making it very hard to workaround. For reference 0.05 * 21.9500 * 6 = 6.585
Comment by Peter F.
29260 | July 09, 2018 07:01:20 PM GMT
+1 ………..
Vote by Aaron N.
29349 | July 14, 2018 08:33:21 PM GMT