Nonsensical attempt to avoid "funnily rounded" float numbers in RosettaStats.asPercentage()

Bug #720199 reported by Abel Deuring
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
Low
Abel Deuring

Bug Description

It seems that the method RosettaStats.asPercentage() tries to avoid output of strings like 3.2999999999999998 by converting a float value into a string and then into a float value again. This is nonsesne. The core of this method as a one-liner in the Python shell:

>>> float(str(round((float(33)/1000)*100, 2)))
3.2999999999999998

Values like 3.3 can never be precisely represented as a binary float value.

If we want a more readable display of such values, callsites should format the value like so:

    '%1.2f' % 3.3

Or we let the method return strings directly.

Related branches

Revision history for this message
Launchpad QA Bot (lpqabot) wrote :
Changed in launchpad:
assignee: nobody → Abel Deuring (adeuring)
milestone: none → 11.03
tags: added: qa-needstesting
Changed in launchpad:
status: Triaged → Fix Committed
William Grant (wgrant)
tags: added: qa-untestable
removed: qa-needstesting
Changed in launchpad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.