Skip to main content

Timeline for answer to Rounding Numbers by Dead Possum

Current License: CC BY-SA 4.0

Post Revisions

6 events
when toggle format what by license comment
Jun 7, 2018 at 14:59 comment added ShadowRanger @ovs: Using more modern formatting (i.e. the str.format method, not printf-style formatting), you can get it down to 16 bytes (doesn't even require a lambda). My second solution for Python 3 will work identically in Python 2.7 (and only require two more bytes on Python 2.6, to add indices to the formatting placeholders).
Jun 7, 2018 at 13:07 history edited Dead Possum CC BY-SA 4.0
added 16 characters in body
Jun 7, 2018 at 1:49 comment added ovs 24 bytes
Jun 6, 2018 at 18:53 comment added ShadowRanger @12Me21: Not relevant, since 0.02675 doesn't actually exist as an exact value in IEEE 754 binary64 floating point (which most languages use as the basis for floating point math; you'll get the same issues with Java, JavaScript, C#, C [compiler dependent], etc.). The closest value is something like 0.02674999999999999947, with 0.02675 being a convenient shorthand. Floating point math is broken from a human perspective
Jun 6, 2018 at 18:36 comment added 12Me21 Fails on 0.02675, 4
Jun 6, 2018 at 15:21 history answered Dead Possum CC BY-SA 4.0