for integer/bigint type while format to scientific notation, automatically get the correct number of precision

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: for integer/bigint type while format to scientific notation, automatically get the correct number of precision
Date: 2022-11-08 08:49:34
Message-ID: CACJufxHcBYmC=7W=05gbEkxU7WAygSr4_U=2AH2YWOVBp23KpA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

looking for the reverse of select '1.2923904e+07'::numeric::int;
every time, I have to select to_char(12923904,'9.9999999EEEE');
if I do select to_char(12923904,'9.999999EEEE');
then the result is different.

For integer or bigint can I automatically have something like:
select to_char(int,'9.(precision-1)EEEE');

--
I recommend David Deutsch's <<The Beginning of Infinity>>

Jian

Browse pgsql-general by date

  From Date Subject
Next Message Cedric Aaron Towstyka 2022-11-08 10:50:18 Information to CVE-2022-42889
Previous Message Jan Bilek 2022-11-08 07:35:02 Re: PCI:SSF - Safe SQL Query & operators filter