Representation of floats (-> Mark Dickinson?)
jmfauth
wxjmfauth at gmail.com
Wed Sep 7 02:32:07 EDT 2011
On 7 sep, 05:58, casevh <cas... at gmail.com> wrote:
> ...
>
> Also note that 1.1 * 1.1 is not the same as 1.21.
>
> >>> (1.1 * 1.1).as_integer_ratio()
>
> (5449355549118301, 4503599627370496)>>> (1.21).as_integer_ratio()
>
> (1362338887279575, 1125899906842624)
>
> This doesn't explain why 2.7.2 displayed a different result on your
> computer. What do you get for as_integer_ratio() for (1.1 * 1.1) and
> (1.21)?
>
Sure. I just picked up these numbers/expressions by chance. They
came to my mind following the previous discussion.
Sticking with the latest versions:
>>> sys.version
'2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]'
>>> (1.1 * 1.1).as_integer_ratio()
(5449355549118301L, 4503599627370496L)
>>> (1.21).as_integer_ratio()
(1362338887279575L, 1125899906842624L)
>>>
>>> sys.version
'3.2.2 (default, Sep 4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)]'
>>> (1.1 * 1.1).as_integer_ratio()
(5449355549118301, 4503599627370496)
>>> (1.21).as_integer_ratio()
(1362338887279575, 1125899906842624)
>>>
Has "long" not disappeared 2.7?
I have not the skill to dive into the machinery. I have
only some theroretical understanding and I'm a little bit
confused and have to face "there something strange
somewhere".
Test on Windows 7, 32 bits.
jmf
More information about the Python-list
mailing list