[issue13889] str(float) and round(float) issues with FPU precision

Stefan Krah report at bugs.python.org
Tue Mar 13 15:35:06 CET 2012


Stefan Krah <stefan-usenet at bytereef.org> added the comment:

Mark Dickinson <report at bugs.python.org> wrote:
> http://msdn.microsoft.com/en-us/library/e9b52ceh(v=vs.100).aspx
> Question 1:  when doing __control87_2(new, mask, &old, NULL), does the
> resulting value in old reflect the *new* FPU state or the old one?

The new one, but I had to test that manually (see below).

> Question 2:  in the example near the bottom of that page, there's code like:
> 
>     control_word_x87 = __control87_2(_PC_24, MCW_PC,
>                                      &control_word_x87, 0);
> 
> This looks very odd: we're assigning to control_word_x87, *and* passing it as an output parameter to the call.  Moreover, from the documentation  the return value from __control87_2 is always 1 to indicate success, so I'm not sure why it's being assigned to control_word_x87.
> 
> Am I the only person who's confused by this?

I was confused as well. I'm positive that it's a cut-and-paste bug in the docs:
Probably they had _control87() in that place before, which *does* return the
new control word. As you say, the example above clobbers the value that was set
via the pointer reference, so the result is always 1. :)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13889>
_______________________________________


More information about the Python-bugs-list mailing list