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

  • From: fanoIlprimo@xxxxxxxxx
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sun, 04 Dec 2011 19:28:48 +0000

Il giorno , Adrien Destugues <pulkomandy@xxxxxxxxxxxxxxxxx> ha scritto:
You're doing things in fixed precision, so you should't use floats or

doubles.

Do all your math using cents, then *divide* by 100 in the end to get a

value in euros, dollars, or whatever. This way there will be no

rounding error.

I do all math in cents and then divide by 100 and cast to int, and I've rounding errors...
guaranteed :-)

It's easy enough in C++ to write some support classes for your own

software if you need to do this a lot. I see no need for doing it at

compiler level.



--

Adrien.

Well Adrien, YOU, have NOT to do nothing, GCC has already done it!
_Decimal32 is a ***native*** type in C and decimal32 is already the class I want in C++ :-) simply we've to find the way to enable them in the compiler, yes I can find a way (in c++, in c it's very difficult in an elegant way, IMHO) to do an imitation of them, but why reinvent the wheel?

Thanks
fano

Other related posts: