Re: [HACKERS] Floating point error

From: James Cloos <cloos(at)jhcloos(dot)com>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: Kevin Grittner <kgrittn(at)ymail(dot)com>, Daniel Farina <daniel(at)heroku(dot)com>, Maciek Sakrejda <m(dot)sakrejda(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>, Tom Duffey *EXTERN* <tduffey(at)trillitech(dot)com>, "pgsql-general\(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>, "pgsql-hackers\(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] Floating point error
Date: 2013-03-05 16:36:29
Message-ID: m31ubtajmh.fsf@carbon.jhcloos.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

>>>>> "HL" == Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> writes:

HL> It would be nice to have a base-2 text format to represent floats.
HL> It wouldn't be as human-friendly as base-10, but it could be used
HL> when you don't want to lose precision. pg_dump in particular.

hexidecimal notation for floats exists. The printf format flag is %a
for miniscule and %A for majuscule.

The result of 1./3. is 0xa.aaaaaaaaaaaaaabp-5.

This site has some info and a conversion demo:

http://gregstoll.dyndns.org/~gregstoll/floattohex/

-JimC
--
James Cloos <cloos(at)jhcloos(dot)com> OpenPGP: 1024D/ED7DAEA6

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Maciek Sakrejda 2013-03-05 16:37:58 Re: [HACKERS] Floating point error
Previous Message Tom Lane 2013-03-05 14:52:34 Re: 9.2 timestamp function syntax error

Browse pgsql-hackers by date

  From Date Subject
Next Message Maciek Sakrejda 2013-03-05 16:37:58 Re: [HACKERS] Floating point error
Previous Message Alvaro Herrera 2013-03-05 16:25:44 Re: sql_drop Event Triggerg