Opened 10 years ago

Last modified 6 years ago

#7174 new enhancement

Decimal Floating Point support

Reported by: fano Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: System/POSIX Version: R1/alpha2
Keywords: Cc:
Blocked By: Blocking:
Platform: All


In these days I was working (on Linux) on an application in which I have to represent currency and seemed natural to me to use double to represent it! A great mistake now I know... double simply not work (that is I have 0.05 I multiply for 2 and obtain... 0.09 not 0.10!).

I have found that there is a new _Decimal type in the work and GCC say it is included from GCC 4.2, but sadly is not compiled by default... so in Linux it says: _Decimal32 not found! ... and I've to re-write to use integer and divide by 100 for visualization :-(

I've tried this simple C code on Haiku and it is better:

#include <stdio.h>

main(void) {
    _Decimal32 d = 4.0;

     return 0;

GCC says: << decimal floating point not supported for this target >>

Better that Linux that says _Decimal32 not exist! But why is not supported? This support can be added? I think Decimal Floating point could be very useful if you want precise decimal calculation...

For references:

Change History (3)

comment:1 by fano, 10 years ago

I've tried to recompile gcc in the Haiku svn tree adding at configure --enable-decimal-float=true and I've done make... after a lot of checking I obtain:

checking if compiler knows _Decimal64... configure: error: Compiler doesn't know _Decimal64; try GCC >= 4.2, configured with --enable-decimal-float
make[2]: *** [configure-stage1-mpfr] Error 1
make[2]: Leaving directory `/boot/home/Desktop/HAIKUsrc/haiku/haiku/buildtools/gcc'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/boot/home/Desktop/HAIKUsrc/haiku/haiku/buildtools/gcc'
make: *** [all] Error 2

OK, the GCC that is compiling does not know _Decimal64, but it is for this I'm recompiling it! I do not understand to compile GCC with _Decimal64 sypport I've to use a gcc that knows of them?

Probably I'm doing something wrong... it seems a case of deadlock!

comment:2 by fano, 9 years ago

Adding reference to ML discussion:

Summary: we should not trust GCC as a lot of time they broke backward compatibility (and in the end we hope to pass to LLVM/Clang as compiler), so maybe it's better to develop a native Haiku decimal class.

comment:3 by pulkomandy, 6 years ago

Milestone: R1Unscheduled
Note: See TracTickets for help on using tickets.