Re: [HACKERS] Re: Trouble with float4 afterupgrading from 6.5.3 to 7.0.2
I suppose we could implement the conversion as "float8in(float4out(x))"
instead of "(double) x" but it'd be several orders of magnitude slower,
as well as being *less* useful to those who know what they're doing with
float math (since the result would actually be a less-precise conversion
except in cases where the intended value has a short decimal
representation).
We only need to maintain the lower-order bit(s). Seems this could be done
a lot easier than by an ascii in-between.
Is there a reason we can't perform the conversion and then copy the
low-order bits manually, with some bit-shifting and masking?
Ian
Import Notes
Reply to msg id not found: 6672.965667230@sss.pgh.pa.us
Is there a reason we can't perform the conversion and then copy the
low-order bits manually, with some bit-shifting and masking?*What* low-order bits? The fundamental problem is we don't have 'em.
OK, we represent 10.1 (decimal) with 1010.000110011..., repeating the 0011
pattern. In floating point representation, we say this is 2^3 *
1.010000110011..., repeating the 0011 pattern.
But this dosen't work very well, because when we print it out it won't be
exact, it will be some decimal number ending in a 0 or a 5. So when we
read this out in decimal, we get 10.099999995, with a variable number of
9's depending on the precision we use.
When we print this number out, we perform the decimal conversion, and then
truncate the last decimal digit and round.
So I guess the question is, why can't we perform 4-bit float -> 8-bit
float conversion via a decimal conversion, irrespective of storing the
thing in ASCII.
Mabye the decimal conversion is too costly? Perhaps we could 1) mark 4-bit
floats with a flag of some kind indicating whether or not the decimal
conversion is necessary, and 2) avoid this conversion wherever possible,
including giving people a warning when they use float4s in their tuples.
Or mabye I'm just being dumb.
Ian
Import Notes
Reply to msg id not found: 7292.965674659@sss.pgh.pa.us | Resolved by subject fallback
<vectro@pipeline.com> writes:
Is there a reason we can't perform the conversion and then copy the
low-order bits manually, with some bit-shifting and masking?
*What* low-order bits? The fundamental problem is we don't have 'em.
regards, tom lane