From: Tom Lane <tgl@sss.pgh.pa.us>
To: Sun, Way <Way.Sun@sciatl.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: libpq: PQexecParams, binaryFormat and float
Date: Fri, 29 Jun 2007 16:27:18 -0400
Message-ID: <8175.1183148838@sss.pgh.pa.us> (raw)
In-Reply-To: <7FBC16D72C0ABF45A88EAEB9ED3464C48CC172@sausatlexch01.corp.sa.net>
References: <7FBC16D72C0ABF45A88EAEB9ED3464C48CC172@sausatlexch01.corp.sa.net>
"Sun, Way" <Way.Sun@sciatl.com> writes:
> float loadavg;
> loadavg = htonl(1.23);
It seems entirely unlikely that that will produce a byte-reversed float
value; what I think will happen is that the byte-reversed value of
integer 1 will be converted into a host-format float and stored into
loadavg.
AFAIK you can't really do this in C without a union. Take a look at
pq_sendfloat4 and pq_getmsgfloat4 in the backend for examples.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: tgl@sss.pgh.pa.us, Way.Sun@sciatl.com
Subject: Re: libpq: PQexecParams, binaryFormat and float
In-Reply-To: <8175.1183148838@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox