Victor Eijkhout wrote:
I have two long ints, both too long to convert to float, but their ratio
is something reasonable. How can I compute that? The obvious "(1.*x)/y"
does not work.

Victor.

You don't make clear what you mean by "too long to convert to float." Do you mean can't convert exactly, or that they're more than 400 digits or whatever the exponent limit of float is (I'm too lazy to look it up right now) ?

Assuming the latter, you could divide each by the same constant, then use your formula above to make a float version of the ratio. How to pick the constant? How about the smaller of your numbers, divided by 1e18 ? You'd have to build that number using longs as well.

Alternatively, you could build your own floating point library, using longs as the mantissa.

DaveA

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to