Skip site navigation (1) Skip section navigation (2)

Re: libpq: PQexecParams, binaryFormat and float

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Sun, Way" <Way(dot)Sun(at)sciatl(dot)com>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: libpq: PQexecParams, binaryFormat and float
Date: 2007-06-29 20:27:18
Message-ID: 8175.1183148838@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-interfaces
"Sun, Way" <Way(dot)Sun(at)sciatl(dot)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

In response to

pgsql-interfaces by date

Next:From: Richard FranklandDate: 2007-07-09 22:46:06
Subject: Re: libpq: PQexecParams, binaryFormat and float
Previous:From: Sun, WayDate: 2007-06-29 19:09:22
Subject: libpq: PQexecParams, binaryFormat and float

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group