David T. Ashley
dashley at abi-consulting.com
Wed Apr 27 03:00:09 CEST 2005
> While the standard function, exp(), doesn't seem to exist for rational
> numbers, I see that an alternative form, mpq_div_2exp() does exist. I
> feel like there should be some way to represent exp(-a) as y / 2^x, but
> with the constraint that x be an integer the best method of
> representation isn't immediately obvious to me.
Where you're trying to go has absolutely confused me.
like there should be some way to represent exp(-a) as y / 2^x
As best I can tell, you are wanting to use the GMP to approximate real
numbers as a 2-tuple, where one integer is the mantissa and the other is the
exponent used to exponentiate 2.
Every arbitrary-precision floating-point package does exactly that under the
hood, so why do it again. The nature of fixed-point arithmetic is that the
radix point is between two bits somewhere, and that necessarily implies that
the number is expressible as y/2^x.
If you want to re-implement an arbitrary-precision floating-point package
using GMP ... it will only waste your time.
What did I miss?
More information about the gmp-discuss