Opened 14 years ago
Last modified 10 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 |
Description
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> int 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 , 14 years ago
comment:2 by , 13 years ago
Adding reference to ML discussion: http://www.freelists.org/post/haiku-development/gcc-enable-Decimal32-Deimal64-and-Decimal128-and-g-decimal32-support
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 , 10 years ago
Milestone: | R1 → Unscheduled |
---|
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:
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!