toString() trims zeros after decimal point for BigDecimal string representation

Description

Workaround is thus either .toString() or numberFormat().

Activity

Show:

Michael Offner 15 June 2018 at 14:58


the behaviour in Lucee on this has not changed.
when i run your code with Lucee 5.2, 4.5 and Railo 4.2 i always get "1 KB"
https://trycf.com/gist/a5b6196c7fa58a9ad506595f4cd4c3a7/lucee?theme=monokai

in addition it is consistent with how Lucee handles number in general (and ACF as well btw)
Take this example
https://trycf.com/gist/650b303906541331a2fb39d794cae11c/lucee5?theme=monokai

Lucee return "1 KB" in all cases, ACF returns "1 KB" in case the numbers are doubles or strings, but not for BigDecimal.
That is inconsistent behaviour in ACF on my side.

Alexander Kwaschny 24 May 2018 at 20:18

I encountered this in one of my unit tests for a function that converts number of Bytes to KB/MB/GB. The issue occurs when concatenating said number with a string. To demonstrate it:

Lucee suddenly trimming decimal places is simply an unexpected behavior, that's about it.

Brandon Brown 24 May 2018 at 11:09

I am personally not affected by this as I don’t use anything like what the OP does in my code and I would have no problem using NumberFormat.

Michael Offner 24 May 2018 at 08:06

"toString" is not a member function it is a object method, in other words an undocumented feature coming from the underlying java layer, BUT you have a point there.
But let me repeat, how are you affected by this?
I'm asking to understand the implication the current behaviour has for users.

Brandon Brown 24 May 2018 at 02:31

I am on the fence about this. I agree it could break things which is never good but also there is inconsistency in the way Lucee returns the number using the member function vs using the "traditional" function call. I would expect them to return the same, either with or without the decimal, regardless of the "toString" method used.

Details

Assignee

Reporter

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Affects versions

Priority

Created 9 May 2018 at 21:05
Updated 15 June 2018 at 14:58