Open hasithaa opened 2 years ago
One point is that the string format should preserve the precision. Generally, it shouldn't use exponential format except when necessary i.e. 1000 should be written as 1000 not 1.000e3.
There is the same problem with float. See #909. Float is actually more underdefined because float values do not have a precision.
@hasithaa More control over conversion of numbers to strings is issue #770.
One way for decimal to string to work is like this:
http://speleotrove.com/decimal/daconvs.html#reftostr
I don't fully understand the thinking behind that.
As of 2022R1, the spec says little about decimal
toString
representation and it doesn't mention when to use scientific notation, etc. https://github.com/ballerina-platform/ballerina-spec/blob/6eeb0610413fc0de4077114eb7afa45cfa410d9e/lang/spec.html#L3348-L3379The jBallerina implementation follows Java conventions. i.e. Scientific notation etc.