Ok, thanks. Not fluent enough in C to be able to help. But I wrote a function that basically does the job, although
someextra parameter could be added to control the formatting:
create function sci (x float) returns text as $$ select
regexp_replace(to_char(x,'9.99EEEE'),'(.+)e(-*)(\+*)(0*)(.+)',E'$\\1\\cdot10\^{\\2\\5}$') $$
Example:
select sci(0.003337),sci(5678);
sci | sci
----------------------+---------------------
$ 3.34\cdot 10^{-3}$ | $ 5.68\cdot 10^{3}$
(1 row)
/ Peter
On 2012-10-18, at 20:55 , Andrej wrote:
> On 19 October 2012 01:38, Peter Wintoft <peter@lund.irf.se> wrote:
>> What language is used for patches?
>
> C
>
>>
>> / Peter
> Cheers,
> Andrej