Re: Output float number with hex format

From: Vincenzo Romano <vincenzo(dot)romano(at)notorand(dot)it>
To: 沈雷 <drshenlei(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Output float number with hex format
Date: 2010-01-29 07:31:27
Message-ID: 3eff28921001282331k54d536bfr9ca3f0fad3b85f75@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2010/1/29 沈雷 <drshenlei(at)gmail(dot)com>:
> Hi!
>
> In C Language, there is a way to format float numbers into a hex string by
> using "%a" in printf.
> eg:
> the value: 1.2345 can be expressed as '0x1.3c083126e978dp+0' which is the
> hex representation of a float number.
>
> I have tried this in Postgres:
> SELECT '0x1.3c083126e978dp+0'::float;
>  float8
> --------
>  1.2345
> (1 row)
> This means that Postgres can accepty hex float as *input*. However I cannot
> find any format function for *output*.
> to_char(..., ...) does not have "%a"-like format. Is there any way to do
> that?
>
> Thank you in advance.
>
> --
> ShenLei

Well, your question sould be about a scanf, not printf, as this is
input, not output.
While being an "interesting" feature, I don't see and use for it.
And, in my opinion, this is not the first and only feature that works
and is not documented.
So, please, don't rely on it until it gets documented.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2010-01-29 07:32:08 Re: dynamic crosstab
Previous Message 沈雷 2010-01-29 03:48:46 Output float number with hex format