question about math module notation
Dan Bishop
danb_83 at yahoo.com
Thu Jul 26 20:20:29 EDT 2007
On Jul 26, 3:59 pm, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> brad <byte8b... at gmail.com> writes:
> > Ah yes, that works too... thanks. I've settled on doing it this way:
> > print int(math.pow(2,64))
> > I like the added parenthesis :)
>
> I was surprised to find that gives an exact (integer, not
> floating-point) answer. Still, I think it's better to say 2**64
> which also works for (e.g.) 2**10000 where math.pow(2,10000)
> raises an exception.
It *is* binary floating point. Powers of 2 are exactly
representable. Of course, it doesn't give an exact answer in general.
>>> int(math.pow(10, 23))
99999999999999991611392L
More information about the Python-list
mailing list