Re: Lossless transmission of double precision floating point

From: "Michael J(dot) Baars" <mjbaars1977(dot)pgsql(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Lossless transmission of double precision floating point
Date: 2025-07-19 09:38:48
Message-ID: CALudE+4TyCjq9kxCqaPbsQKA9yYHcS=45XsO_uFK8cOhQB-8WQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jul 18, 2025 at 4:12 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> "Michael J. Baars" <mjbaars1977(dot)pgsql(at)gmail(dot)com> writes:
> > I receive data from a data provider on a daily basis, and noticed how they
> > use fixed type floating point in text mode, to transmit data. As you might
> > know, this type of transmission is not lossless.
>
> It is if you use enough decimal digits. Are you sure you're not
> inventing something to worry about?

The graphs speak for themselves. They do have a problem with accuracy
in the lower digits. Transmitting doubles as byte arrays takes less
characters (especially for very small numbers) and is 100% accurate.

The current solution would be to combine the data stream and its
inverse into one, depending on the two numbers being above or below
1.0. But that is a pretty ugly client side solution.

>
> regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael J. Baars 2025-07-19 09:44:46 Re: Upgrade from Fedora 40 to Fedora 42, or from PostgreSQL 16.3 to PostgreSQL 16.9
Previous Message vignesh C 2025-07-19 06:45:31 Re: Log prefix missing for subscriber log messages received from publisher