Opened 15 years ago

Closed 14 years ago

#13810 closed Bug (fixed)

number format routine improvement

Reported by: milosu Owned by: nobody
Component: Core (Other) Version: dev
Severity: Normal Keywords:
Cc: david.danier@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

in nuberformat format(), decimal_pos == 0 should effectively remove the decimal part and decimal_pos < len(dec_part) should truncate the decimal part. patch attached.

Attachments (2)

number_format.patch (790 bytes ) - added by milosu 15 years ago.
number_format_r13401.patch (1.8 KB ) - added by Łukasz Rekucki 14 years ago.

Download all attachments as: .zip

Change History (7)

by milosu, 15 years ago

Attachment: number_format.patch added

by Łukasz Rekucki, 14 years ago

Attachment: number_format_r13401.patch added

comment:1 by Łukasz Rekucki, 14 years ago

Triage Stage: UnreviewedAccepted

The truncate part is already there, but the condition was incorrect, so I just fixed that instead of adding more checks. Also, added a test. Currently format() allows negative decimal_pos (which means, print N positions less than you would normally). I don't really have a use case for that, but I see no harm in allowing it.

comment:2 by David Danier <david.danier@…>, 14 years ago

Cc: david.danier@… added

comment:3 by Graham King, 14 years ago

Component: UncategorizedCore (Other)
Severity: Normal
Type: Bug

comment:4 by Julien Phalip, 14 years ago

Triage Stage: AcceptedReady for checkin

This looks great to me.

comment:5 by Jannis Leidel, 14 years ago

Resolution: fixed
Status: newclosed

In [16074]:

Fixed #13810 -- Truncate numbers correctly when given number of decimal positions is zero. Thanks, milosu and Łukasz Rekucki.

Note: See TracTickets for help on using tickets.
Back to Top