This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [libstdc++] decimal float support (take 3)


Ed Smith-Rowland wrote:
Benjamin Kosnik wrote:
If the documentation says that the decimal header is supported when
the C++ compiler supports scalar decimal floating-point arithmetic
via types defined with __attribute((mode(SD|DD|TD))), is it OK if the
header is always installed?

Yes. That's the joy of putting it in tr24733 (not because it's documented.)

As long as it's not in the default place then we're all cool all the
time.

There are several parts of TR 24733 that are not yet implemented, and
I have questions about some of those. What's a good forum for
discussing those?

Apparently, this one.
2009-10-01 Janis Johnson <janis187@us.ibm.com>

* doc/Makefile.am: Process new file.
* doc/xml/manual/intro.xml: Ditto.
* doc/xml/manual/using.xml: Document new header.
* doc/xml/manual/status_cxxtr24733.xml: New file.
* include/Makefile.am: Process new headers.
* include/tr24733/decimal: New file.
* include/tr24733/decimal.h: New file.

This, plus the testsuite patch, and with my small fixes are attached.


The attached version is ok to check in. I've built and tested it on
x86_64/linux, generated all the docs.
Please wait 24 hours for Paolo or others to comment or disagree.

Index: libstdc++-v3/include/tr24733/decimal
+
+ // ISO/IEC TR 24733 3.2.7 Unary arithmetic operators.
+ decimal32 operator+(decimal32 __rhs);
+ decimal64 operator+(decimal64 __rhs);
+ decimal128 operator+(decimal128 __rhs);
+ decimal32 operator-(decimal32 __rhs);
+ decimal64 operator-(decimal64 __rhs);
+ decimal128 operator-(decimal128 __rhs);
+
+ // ISO/IEC TR 24733 3.2.8 Binary arithmetic operators.
+#define _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(_Op, _T1, _T2,
_T3) \
+ _T1 operator _Op(_T2 lhs, _T3 __rhs);
+#define _DECLARE_DECIMAL_BINARY_OP_WITH_INT(_Op, _Tp)
\
+ _Tp operator _Op(_Tp lhs, int
__rhs); \
+ _Tp operator _Op(_Tp lhs, unsigned int __rhs); \
+ _Tp operator _Op(_Tp lhs, long __rhs); \
+ _Tp operator _Op(_Tp lhs, unsigned long __rhs); \
+ _Tp operator _Op(_Tp lhs, long long __rhs);
\
+ _Tp operator _Op(_Tp lhs, unsigned long long
__rhs); \
+ _Tp operator _Op(int lhs, _Tp
__rhs); \
+ _Tp operator _Op(unsigned int lhs, _Tp __rhs); \
+ _Tp operator _Op(long lhs, _Tp __rhs); \
+ _Tp operator _Op(unsigned long lhs, _Tp __rhs); \
+ _Tp operator _Op(long long lhs, _Tp __rhs);
\
+ _Tp operator _Op(unsigned long long lhs, _Tp __rhs);
+
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal32, decimal32,
decimal32)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_INT(+, decimal32)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal32,
decimal64)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal64,
decimal32)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal64,
decimal64)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_INT(+, decimal64)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal32,
decimal128)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal64,
decimal128)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128,
decimal32)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128,
decimal64)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128,
decimal128)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_INT(+, decimal128)
+
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal32, decimal32,
decimal32)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_INT(-, decimal32)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal32,
decimal64)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal64,
decimal32)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal64,
decimal64)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_INT(-, decimal64)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal32,
decimal128)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal64,
decimal128)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128,
decimal32)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128,
decimal64)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128,
decimal128)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_INT(-, decimal128)
+
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal32, decimal32,
decimal32)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_INT(*, decimal32)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal32,
decimal64)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal64,
decimal32)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal64,
decimal64)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_INT(*, decimal64)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal32,
decimal128)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal64,
decimal128)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128,
decimal32)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128,
decimal64)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128,
decimal128)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_INT(*, decimal128)
+
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal32, decimal32,
decimal32)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_INT(/, decimal32)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal32,
decimal64)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal64,
decimal32)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal64,
decimal64)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_INT(/, decimal64)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal32,
decimal128)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal64,
decimal128)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128,
decimal32)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128,
decimal64)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128,
decimal128)
+ _DECLARE_DECIMAL_BINARY_OP_WITH_INT(/, decimal128)
+
+#undef _DECLARE_DECIMAL_BINARY_OP_WITH_DEC
+#undef _DECLARE_DECIMAL_BINARY_OP_WITH_INT

YUCK!


You say macro, I say templatized base class. I'm willing to work
through this issue after it's in.

best,
benjamin
I think that in the spirit of having tr1 components in a subdirectory named after the namespace it might be better to have the decimal extension under a decimal directory. That name would make it more recognizable for people and it would be just as "hidden".

Just a thought.

I also found out that make install doesn't install decimal. I may have an older patch though. I'll try it with this one.

Nice work by the way.


I also tried this on a system that didn't have decimal support (I don't know I I needed to explicitly configure or not, it was ppc macos). I think it would be nice to get a _GLIBCXX_HAVE_DECIMAL_FLOAT into c++config.h and then #error gracefully in <decimal>. I'm not familiar enough with the build and config machinery just yet.

Ed


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]