From: | "Peter J(dot) Holzer" <hjp-pgsql(at)hjp(dot)at> |
---|---|
To: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: The same prepared query yield "-1" the first six times and then "-1.0" |
Date: | 2023-08-21 22:05:05 |
Message-ID: | 20230821220505.xxeql573gtnuvccn@hjp.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 2023-08-21 17:31:06 -0400, Dave Cramer wrote:
> On Mon, 21 Aug 2023 at 17:17, Ron <ronljohnsonjr(at)gmail(dot)com> wrote:
>
> On 8/21/23 14:32, Dave Cramer wrote:
>
> [snip]
>
> It has to do with the way the data is being transferred. When the
> driver switches to a named statement it also switches to binary mode
> which means data will be transferred in binary.
>
> In text we get -1, in binary we get -1.0
>
>
> That seems odd. Why does it do that?
[...]
> whereas float8send sends the actual binary data on disk, hence -1.0
It should be noted that the binary representation is not "-1.0", but
something like
1 01111111 00000000000000000000000 (in binary or)
B F 8 0 0 0 0 0 (in hex)
(big endian for better readability)
The decimal representation "-1.0" is created by the binary to string
conversion (Java's Float.toString()?). That could also produce "-1" or
"-1E0" or any other equivalent representation. The author of that
routine decided in include ".0" in the output, possibly to signify that
it's a floating point value, not an integer.
hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp(at)hjp(dot)at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
From | Date | Subject | |
---|---|---|---|
Next Message | Amn Ojee Uw | 2023-08-21 23:41:34 | Re: JDBC + PG-15 but not psql |
Previous Message | Dave Cramer | 2023-08-21 21:31:06 | Re: The same prepared query yield "-1" the first six times and then "-1.0" |