What is the minimum precision allowed for floats.
Décio Luiz Gazzoni Filho
decio at decpp.net
Mon Sep 29 05:05:27 CEST 2008
On Sep 28, 2008, at 5:47 PM, Joel Kronander wrote:
> Hi
>
> I have a question regading the possible minimun precision for floats.
> For example is it possible to use a precision between native c float
> and double
> ie precision digits between 6-15 for exmample.
I suppose you could do it, but why? First of all, you'd be moving from
hardware-accelerated to software-emulated, so I would expect slowdowns
on the order of 10x-100x. If you're doing it hoping to get a speedup,
just trash the idea, it'll never ever work. If you want to save memory
by, say, having a 48-bit float, and you don't care about the slowdown
due to software emulation... well, first of all, GMP probably works
with multiples of 32 or 64 bits, so 48 bits is out of the question,
and besides, I believe it uses a whole limb (i.e. 32 or 64 bits) for
the exponent and whatever is needed for the mantissa, so there'd be a
further waste of memory if that's what you're concerned with. Maybe if
you roll your own package.
I have no idea what you're working with, but have you considered fixed
point rather than floating point? The speed hit shouldn't be too
substantial, and you get the full word for the mantissa (in exchange
for limited dynamic range).
Décio
More information about the gmp-discuss
mailing list