Opened 8 years ago

Closed 7 years ago

#13810 closed Bug (fixed)

number format routine improvement

Reported by: milosu Owned by: nobody
Component: Core (Other) Version: master
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: UI/UX:


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 8 years ago.
number_format_r13401.patch (1.8 KB) - added by Łukasz Rekucki 8 years ago.

Download all attachments as: .zip

Change History (7)

Changed 8 years ago by milosu

Attachment: number_format.patch added

Changed 8 years ago by Łukasz Rekucki

Attachment: number_format_r13401.patch added

comment:1 Changed 8 years ago by Łukasz Rekucki

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 Changed 8 years ago by David Danier <david.danier@…>

Cc: david.danier@… added

comment:3 Changed 7 years ago by Graham King

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

comment:4 Changed 7 years ago by Julien Phalip

Triage Stage: AcceptedReady for checkin

This looks great to me.

comment:5 Changed 7 years ago by Jannis Leidel

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