Re: rounding problems

From: Justin <justin(at)emproshunts(dot)com>
To: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>, pgsql-general(at)postgresql(dot)org
Subject: Re: rounding problems
Date: 2008-05-12 21:02:30
Message-ID: 4828B066.6050101@emproshunts.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Craig Ringer wrote:
> Justin wrote:
>
>> No floating point is being used every variable is declared as numeric
>> on the Postgresql side and in the C++ which is the UI side
>> everything is double.
>
> `double' in C++ refers to double precision floating point. `double' is
> subject to all the usual fun with rational decimals being irrational
> binary floats (and vice versa).
>
> One of the reasons I chose Java for my current work is that it has a
> built-in decimal type (like `numeric') called BigDecimal . This makes
> working with exact quantities a lot easier as there's no conversion
> and rounding occurring each time data goes to/from the database.
Not according to MS specific if i'm reading it correctly

*Microsoft Specific >*

The double type contains 64 bits: 1 for sign, 11 for the exponent, and
52 for the mantissa. Its range is +/--1.7E308 with at least 15 digits of
precision
>
> Are there any particular decimal/numeric libraries people here like to
> use with C++ ? Or do you just use double precision floats and a good
> deal of caution?
>
> I'd expect that using double would be OK so long as the scale of your
> numeric values never approaches the floating point precision limit of
> the double type. I'm far from sure about that, though, and it'd be
> handy to hear from people who're doing it. Personally I like to stick
> to numeric/decimal types.
>
> --
> Craig Ringer

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Justin 2008-05-12 21:09:57 Re: rounding problems
Previous Message Craig Ringer 2008-05-12 20:42:44 Re: changing the endianness of a database