[Haskell-cafe] custom SQL-to-Haskell type conversion in HDBC

Erik Hesselink hesselink at gmail.com
Sat Aug 20 13:41:22 CEST 2011


On Friday, August 19, 2011, Brandon Allbery <allbery.b at gmail.com> wrote:
> On Fri, Aug 19, 2011 at 11:45, Erik Hesselink <hesselink at gmail.com> wrote:
>>
>> Note that PostgreSQL also doesn't work with decimals as precision:
>>
>> postgres=# select 1::decimal(4,2) * 1::decimal(4,2);
>> ?column?
>> ----------
>>   1.0000
>> (1 row)
>>
>> That should be 1.00 instead if you want the precision correctly
represented.
>
> Er?  Last I checked, that was exactly how precision worked over
multiplication; otherwise you are incorrectly discarding precision present
in the original values.  Unless you're assuming the OP actually wants an
incorrect flat precision model....

This is the way I was taught to do it in physics. See also
http://en.m.wikipedia.org/wiki/Significance_arithmetic

Erik

>
> --
> brandon s allbery                                      allbery.b at gmail.com
> wandering unix systems administrator (available)     (412)
475-9364 <tel:%28412%29%20475-9364> vm/sms
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110820/9101016e/attachment.htm>


More information about the Haskell-Cafe mailing list