Opened 5 years ago

Closed 4 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:

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 5 years ago.
number_format_r13401.patch (1.8 KB) - added by lrekucki 5 years ago.

Download all attachments as: .zip

Change History (7)

Changed 5 years ago by milosu

Changed 5 years ago by lrekucki

comment:1 Changed 5 years ago by lrekucki

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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

  • Cc david.danier@… added

comment:3 Changed 4 years ago by graham_king

  • Component changed from Uncategorized to Core (Other)
  • Severity set to Normal
  • Type set to Bug

comment:4 Changed 4 years ago by julien

  • Triage Stage changed from Accepted to Ready for checkin

This looks great to me.

comment:5 Changed 4 years ago by jezdez

  • Resolution set to fixed
  • Status changed from new to closed

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