Message280996
OK, not wrong, just unexpected.
Is this behaviour documented? Or are you just expected to know what C does?
On 16 November 2016 at 21:37, Mark Dickinson <report@bugs.python.org> wrote:
>
> Mark Dickinson added the comment:
>
> You don't say why you think this behaviour is wrong, or what you'd expect
> to see instead.
>
> Nevertheless, this behaviour is by design: the code `'%.1f' % x` rounds
> `x` to the nearest one-digit-after-the-point decimal number, and returns a
> string representation of that number. In the case `x=0.25`, there is no
> single nearest number: `0.2` and `0.3` are equally close to `0.25`, so a
> choice between the two has to be made. In keeping with many other
> languages, Python chooses the value with even last digit. (The original
> behaviour is inherited from the typical behaviour of the standard library
> strtod or dtoa functions in C.)
>
> ----------
> nosy: +mark.dickinson
> resolution: -> not a bug
> stage: -> resolved
> status: open -> closed
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue28717>
> _______________________________________
>
--
Dr. William McIlhagga
Bradford School of Optometry & Vision Science,
Bradford University
Great Horton Road
Bradford BD7 1DP
UK
Room G23, Richmond tel. (44) (1274) 235957 |
|
Date |
User |
Action |
Args |
2016-11-16 21:53:01 | William McIlhagga | set | recipients:
+ William McIlhagga, mark.dickinson |
2016-11-16 21:53:01 | William McIlhagga | link | issue28717 messages |
2016-11-16 21:53:00 | William McIlhagga | create | |
|