Re: Latex formatting - Mailing list pgsql-novice

From Peter Wintoft
Subject Re: Latex formatting
Date
Msg-id B9093982-ECE8-485C-82BF-FE128C01E7B9@lund.irf.se
Whole thread Raw
In response to Re: Latex formatting  (Andrej <andrej.groups@gmail.com>)
List pgsql-novice
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



pgsql-novice by date:

Previous
From: Andrej
Date:
Subject: Re: Latex formatting
Next
From: Gary Warner
Date:
Subject: "Voting" question?