Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #2039 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

Incorrect string representation of truncated floating point values

Reported by: SiegeLord Assigned to: community
Priority: major Milestone: 1.0
Component: Tango Version: trunk
Keywords: Cc:

Description

This code has an incorrect output in Tango trunk:

Stdout.formatln("{:e2}", 0.09999); // Outputs 1.00e-02

I traced this to a bug inside convertl function in tango.text.convert.Float. What happens it that when the floating point is rounded up because of truncation the exponent is not modified to reflect the change in decimal point. Attached is a patch that fixes this. All the unittests in tango.text.convert.Layout pass with it applied.

Attachments

convertl.diff (401 bytes) - added by SiegeLord on 02/16/11 20:26:46.

Change History

02/16/11 20:26:46 changed by SiegeLord

  • attachment convertl.diff added.

02/19/11 09:11:10 changed by mwarning

I get the same ouput. Applying the patch changes the output to "1.00e-01". Seems to be ready for commit. An additional test for the unittests in Float.d would be nice though.

02/22/11 22:31:25 changed by SiegeLord

I tested the unittests in Float.d and they pass with the patch as well.

02/23/11 17:40:56 changed by mwarning

  • status changed from new to closed.
  • resolution set to fixed.

(In [5617]) fixes #2039 :: Incorrect string representation of truncated floating point values; thanks to SiegeLord?