Confusing math problem
schiz_man at 21stcentury.com
Fri Feb 22 00:41:28 CET 2013
"Oscar Benjamin" <oscar.j.benjamin at gmail.com> wrote in
> Then you want operator.pow:
>>>> import operator
>>>> operator.pow(3, 2)
> math.pow is basically the (double)pow(double, double) function from
> the underlying C library. operator.pow(a, b) is precisely the same as
So how is operator.pow() different from just pow()?
> There's no need to use strings if you're working with integers in
> Python. The results with int (not float) will be exact and will not
> overflow since Python's ints have unlimited range (unless your machine
> runs out of memory but that only happens with *really* big integers).
Yes, that's the idea. I haven't really used Python before, so was just
kicking the tyres a bit and got some odd results. This forum has been great
> If you want to do computations with non-integers and high precision,
> take a look at the decimal and fractions modules.
> There is also a good third party library, sympy, for more complicated
> exact algebra:
Thanks a lot for the references, I'll definitely check them out.
More information about the Python-list