[haiku-development] Re: gcc enable _Decimal32, _Deimal64 and _Decimal128 (and g++ decimal32, ...) support

  • From: fano il primo <fanoilprimo@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Tue, 6 Dec 2011 09:54:46 +0100

On Mon, Dec 5, 2011 at 10:23 PM, Stephan Aßmus <superstippi@xxxxxx> wrote:

> Hi,
>
> first of all, the people who are talking about rounding to solve the
> problem don't understand the full scope of the problem. However, what you
> need to do exactly depends on the particular situation. For example, if you
> try to split 100 EUR in three equal parts, you just can't.


Yes me too had the impression the problem is not well understood... I do
not pretend that 100.00 / 3.00 give me a sensate result but on
the other hand 0.60 /3.00 should give me 0.20 and not
0.199999999999999999999999999999999978, right?

It's this problem the IEEE decimal floating point standard tries to solve:
do right math with the number naturally used by human beings
not by 'puters...

So we've 100/3 it 's not representable ( as it does 33.33333(3) ), but 0.6
/3 it is; as in decimal you don't obtain a periodical or transcendent
number.

There will be one cent left which you have to handle in your program
> "somewhere". One particular problem however is precision. To address that,
> I've have done a little research and added the MAPM library as backend to
> DeskCalc, so that the calculator gives you correct values in a lot more
> cases and otherwise returns at least much more precise values than what
> would be possible with doing calculations with "doubles".
>
> Best regards,
> -Stephan
>
>
I think it's better, again, to use the _DecimalXX C native type and
decimalXX C++ native class, bu, in your opinion,
this MAPM library can be the base for a native Haiku decimal class? I
suppose no, it's better to represent fractionary number with
fixed precision...

IBM's *libdecnumber*[1] is better in this sense...
I suppose if we do a Haiku class it works in C++ only and not in C code,
right? Not so important on Haiku to use plain C, but...


Bye,
fano

[1] http://speleotrove.com/decimal/

Other related posts: