Re: Output float number with hex format - Mailing list pgsql-general

From A. Kretschmer
Subject Re: Output float number with hex format
Date
Msg-id 20100129075202.GB28818@a-kretschmer.de
Whole thread Raw
In response to Re: Output float number with hex format  (Vincenzo Romano <vincenzo.romano@notorand.it>)
List pgsql-general
In response to Vincenzo Romano :
> 2010/1/29 ?????? <drshenlei@gmail.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.

I think, you have misinterpreted the question, he is looking for a
output in a hex representation, and he found a way for input.

Hrm, i think, this is possible with pl/perl. For instance.

A. Kretschmer
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431  2EB0 389D 1DC2 3172 0C99

pgsql-general by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: dynamic crosstab
Next
From: Joe Kramer
Date:
Subject: How to generate unique hash-type id?