decimal 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. // <decimal> -*- C++ -*-
  2. // Copyright (C) 2009-2020 Free Software Foundation, Inc.
  3. // This file is part of the GNU ISO C++ Library. This library is free
  4. // software; you can redistribute it and/or modify it under the
  5. // terms of the GNU General Public License as published by the
  6. // Free Software Foundation; either version 3, or (at your option)
  7. // any later version.
  8. // This library is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. // Under Section 7 of GPL version 3, you are granted additional
  13. // permissions described in the GCC Runtime Library Exception, version
  14. // 3.1, as published by the Free Software Foundation.
  15. // You should have received a copy of the GNU General Public License and
  16. // a copy of the GCC Runtime Library Exception along with this program;
  17. // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  18. // <http://www.gnu.org/licenses/>.
  19. /** @file decimal/decimal
  20. * This is a Standard C++ Library header.
  21. */
  22. // ISO/IEC TR 24733
  23. // Written by Janis Johnson <janis187@us.ibm.com>
  24. #ifndef _GLIBCXX_DECIMAL
  25. #define _GLIBCXX_DECIMAL 1
  26. #pragma GCC system_header
  27. #include <bits/c++config.h>
  28. #ifndef _GLIBCXX_USE_DECIMAL_FLOAT
  29. #error This file requires compiler and library support for ISO/IEC TR 24733 \
  30. that is currently not available.
  31. #endif
  32. namespace std _GLIBCXX_VISIBILITY(default)
  33. {
  34. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  35. /**
  36. * @defgroup decimal Decimal Floating-Point Arithmetic
  37. * @ingroup numerics
  38. *
  39. * Classes and functions for decimal floating-point arithmetic.
  40. * @{
  41. */
  42. /** @namespace std::decimal
  43. * @brief ISO/IEC TR 24733 Decimal floating-point arithmetic.
  44. */
  45. namespace decimal
  46. {
  47. class decimal32;
  48. class decimal64;
  49. class decimal128;
  50. // 3.2.5 Initialization from coefficient and exponent.
  51. static decimal32 make_decimal32(long long __coeff, int __exp);
  52. static decimal32 make_decimal32(unsigned long long __coeff, int __exp);
  53. static decimal64 make_decimal64(long long __coeff, int __exp);
  54. static decimal64 make_decimal64(unsigned long long __coeff, int __exp);
  55. static decimal128 make_decimal128(long long __coeff, int __exp);
  56. static decimal128 make_decimal128(unsigned long long __coeff, int __exp);
  57. /// Non-conforming extension: Conversion to integral type.
  58. long long decimal32_to_long_long(decimal32 __d);
  59. long long decimal64_to_long_long(decimal64 __d);
  60. long long decimal128_to_long_long(decimal128 __d);
  61. long long decimal_to_long_long(decimal32 __d);
  62. long long decimal_to_long_long(decimal64 __d);
  63. long long decimal_to_long_long(decimal128 __d);
  64. // 3.2.6 Conversion to generic floating-point type.
  65. float decimal32_to_float(decimal32 __d);
  66. float decimal64_to_float(decimal64 __d);
  67. float decimal128_to_float(decimal128 __d);
  68. float decimal_to_float(decimal32 __d);
  69. float decimal_to_float(decimal64 __d);
  70. float decimal_to_float(decimal128 __d);
  71. double decimal32_to_double(decimal32 __d);
  72. double decimal64_to_double(decimal64 __d);
  73. double decimal128_to_double(decimal128 __d);
  74. double decimal_to_double(decimal32 __d);
  75. double decimal_to_double(decimal64 __d);
  76. double decimal_to_double(decimal128 __d);
  77. long double decimal32_to_long_double(decimal32 __d);
  78. long double decimal64_to_long_double(decimal64 __d);
  79. long double decimal128_to_long_double(decimal128 __d);
  80. long double decimal_to_long_double(decimal32 __d);
  81. long double decimal_to_long_double(decimal64 __d);
  82. long double decimal_to_long_double(decimal128 __d);
  83. // 3.2.7 Unary arithmetic operators.
  84. decimal32 operator+(decimal32 __rhs);
  85. decimal64 operator+(decimal64 __rhs);
  86. decimal128 operator+(decimal128 __rhs);
  87. decimal32 operator-(decimal32 __rhs);
  88. decimal64 operator-(decimal64 __rhs);
  89. decimal128 operator-(decimal128 __rhs);
  90. // 3.2.8 Binary arithmetic operators.
  91. #define _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(_Op, _T1, _T2, _T3) \
  92. _T1 operator _Op(_T2 __lhs, _T3 __rhs);
  93. #define _DECLARE_DECIMAL_BINARY_OP_WITH_INT(_Op, _Tp) \
  94. _Tp operator _Op(_Tp __lhs, int __rhs); \
  95. _Tp operator _Op(_Tp __lhs, unsigned int __rhs); \
  96. _Tp operator _Op(_Tp __lhs, long __rhs); \
  97. _Tp operator _Op(_Tp __lhs, unsigned long __rhs); \
  98. _Tp operator _Op(_Tp __lhs, long long __rhs); \
  99. _Tp operator _Op(_Tp __lhs, unsigned long long __rhs); \
  100. _Tp operator _Op(int __lhs, _Tp __rhs); \
  101. _Tp operator _Op(unsigned int __lhs, _Tp __rhs); \
  102. _Tp operator _Op(long __lhs, _Tp __rhs); \
  103. _Tp operator _Op(unsigned long __lhs, _Tp __rhs); \
  104. _Tp operator _Op(long long __lhs, _Tp __rhs); \
  105. _Tp operator _Op(unsigned long long __lhs, _Tp __rhs);
  106. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal32, decimal32, decimal32)
  107. _DECLARE_DECIMAL_BINARY_OP_WITH_INT(+, decimal32)
  108. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal32, decimal64)
  109. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal64, decimal32)
  110. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal64, decimal64)
  111. _DECLARE_DECIMAL_BINARY_OP_WITH_INT(+, decimal64)
  112. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal32, decimal128)
  113. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal64, decimal128)
  114. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128, decimal32)
  115. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128, decimal64)
  116. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128, decimal128)
  117. _DECLARE_DECIMAL_BINARY_OP_WITH_INT(+, decimal128)
  118. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal32, decimal32, decimal32)
  119. _DECLARE_DECIMAL_BINARY_OP_WITH_INT(-, decimal32)
  120. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal32, decimal64)
  121. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal64, decimal32)
  122. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal64, decimal64)
  123. _DECLARE_DECIMAL_BINARY_OP_WITH_INT(-, decimal64)
  124. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal32, decimal128)
  125. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal64, decimal128)
  126. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128, decimal32)
  127. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128, decimal64)
  128. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128, decimal128)
  129. _DECLARE_DECIMAL_BINARY_OP_WITH_INT(-, decimal128)
  130. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal32, decimal32, decimal32)
  131. _DECLARE_DECIMAL_BINARY_OP_WITH_INT(*, decimal32)
  132. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal32, decimal64)
  133. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal64, decimal32)
  134. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal64, decimal64)
  135. _DECLARE_DECIMAL_BINARY_OP_WITH_INT(*, decimal64)
  136. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal32, decimal128)
  137. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal64, decimal128)
  138. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128, decimal32)
  139. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128, decimal64)
  140. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128, decimal128)
  141. _DECLARE_DECIMAL_BINARY_OP_WITH_INT(*, decimal128)
  142. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal32, decimal32, decimal32)
  143. _DECLARE_DECIMAL_BINARY_OP_WITH_INT(/, decimal32)
  144. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal32, decimal64)
  145. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal64, decimal32)
  146. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal64, decimal64)
  147. _DECLARE_DECIMAL_BINARY_OP_WITH_INT(/, decimal64)
  148. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal32, decimal128)
  149. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal64, decimal128)
  150. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128, decimal32)
  151. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128, decimal64)
  152. _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128, decimal128)
  153. _DECLARE_DECIMAL_BINARY_OP_WITH_INT(/, decimal128)
  154. #undef _DECLARE_DECIMAL_BINARY_OP_WITH_DEC
  155. #undef _DECLARE_DECIMAL_BINARY_OP_WITH_INT
  156. // 3.2.9 Comparison operators.
  157. #define _DECLARE_DECIMAL_COMPARISON(_Op, _Tp) \
  158. bool operator _Op(_Tp __lhs, decimal32 __rhs); \
  159. bool operator _Op(_Tp __lhs, decimal64 __rhs); \
  160. bool operator _Op(_Tp __lhs, decimal128 __rhs); \
  161. bool operator _Op(_Tp __lhs, int __rhs); \
  162. bool operator _Op(_Tp __lhs, unsigned int __rhs); \
  163. bool operator _Op(_Tp __lhs, long __rhs); \
  164. bool operator _Op(_Tp __lhs, unsigned long __rhs); \
  165. bool operator _Op(_Tp __lhs, long long __rhs); \
  166. bool operator _Op(_Tp __lhs, unsigned long long __rhs); \
  167. bool operator _Op(int __lhs, _Tp __rhs); \
  168. bool operator _Op(unsigned int __lhs, _Tp __rhs); \
  169. bool operator _Op(long __lhs, _Tp __rhs); \
  170. bool operator _Op(unsigned long __lhs, _Tp __rhs); \
  171. bool operator _Op(long long __lhs, _Tp __rhs); \
  172. bool operator _Op(unsigned long long __lhs, _Tp __rhs);
  173. _DECLARE_DECIMAL_COMPARISON(==, decimal32)
  174. _DECLARE_DECIMAL_COMPARISON(==, decimal64)
  175. _DECLARE_DECIMAL_COMPARISON(==, decimal128)
  176. _DECLARE_DECIMAL_COMPARISON(!=, decimal32)
  177. _DECLARE_DECIMAL_COMPARISON(!=, decimal64)
  178. _DECLARE_DECIMAL_COMPARISON(!=, decimal128)
  179. _DECLARE_DECIMAL_COMPARISON(<, decimal32)
  180. _DECLARE_DECIMAL_COMPARISON(<, decimal64)
  181. _DECLARE_DECIMAL_COMPARISON(<, decimal128)
  182. _DECLARE_DECIMAL_COMPARISON(>=, decimal32)
  183. _DECLARE_DECIMAL_COMPARISON(>=, decimal64)
  184. _DECLARE_DECIMAL_COMPARISON(>=, decimal128)
  185. _DECLARE_DECIMAL_COMPARISON(>, decimal32)
  186. _DECLARE_DECIMAL_COMPARISON(>, decimal64)
  187. _DECLARE_DECIMAL_COMPARISON(>, decimal128)
  188. _DECLARE_DECIMAL_COMPARISON(>=, decimal32)
  189. _DECLARE_DECIMAL_COMPARISON(>=, decimal64)
  190. _DECLARE_DECIMAL_COMPARISON(>=, decimal128)
  191. #undef _DECLARE_DECIMAL_COMPARISON
  192. /// 3.2.2 Class decimal32.
  193. class decimal32
  194. {
  195. public:
  196. typedef float __decfloat32 __attribute__((mode(SD)));
  197. // 3.2.2.2 Construct/copy/destroy.
  198. decimal32() : __val(0.e-101DF) {}
  199. // 3.2.2.3 Conversion from floating-point type.
  200. explicit decimal32(decimal64 __d64);
  201. explicit decimal32(decimal128 __d128);
  202. explicit decimal32(float __r) : __val(__r) {}
  203. explicit decimal32(double __r) : __val(__r) {}
  204. explicit decimal32(long double __r) : __val(__r) {}
  205. // 3.2.2.4 Conversion from integral type.
  206. decimal32(int __z) : __val(__z) {}
  207. decimal32(unsigned int __z) : __val(__z) {}
  208. decimal32(long __z) : __val(__z) {}
  209. decimal32(unsigned long __z) : __val(__z) {}
  210. decimal32(long long __z) : __val(__z) {}
  211. decimal32(unsigned long long __z) : __val(__z) {}
  212. /// Conforming extension: Conversion from scalar decimal type.
  213. decimal32(__decfloat32 __z) : __val(__z) {}
  214. #if __cplusplus >= 201103L
  215. // 3.2.2.5 Conversion to integral type.
  216. // Note: explicit per n3407.
  217. explicit operator long long() const { return (long long)__val; }
  218. #endif
  219. // 3.2.2.6 Increment and decrement operators.
  220. decimal32& operator++()
  221. {
  222. __val += 1;
  223. return *this;
  224. }
  225. decimal32 operator++(int)
  226. {
  227. decimal32 __tmp = *this;
  228. __val += 1;
  229. return __tmp;
  230. }
  231. decimal32& operator--()
  232. {
  233. __val -= 1;
  234. return *this;
  235. }
  236. decimal32 operator--(int)
  237. {
  238. decimal32 __tmp = *this;
  239. __val -= 1;
  240. return __tmp;
  241. }
  242. // 3.2.2.7 Compound assignment.
  243. #define _DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT(_Op) \
  244. decimal32& operator _Op(decimal32 __rhs); \
  245. decimal32& operator _Op(decimal64 __rhs); \
  246. decimal32& operator _Op(decimal128 __rhs); \
  247. decimal32& operator _Op(int __rhs); \
  248. decimal32& operator _Op(unsigned int __rhs); \
  249. decimal32& operator _Op(long __rhs); \
  250. decimal32& operator _Op(unsigned long __rhs); \
  251. decimal32& operator _Op(long long __rhs); \
  252. decimal32& operator _Op(unsigned long long __rhs);
  253. _DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT(+=)
  254. _DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT(-=)
  255. _DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT(*=)
  256. _DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT(/=)
  257. #undef _DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT
  258. private:
  259. __decfloat32 __val;
  260. public:
  261. __decfloat32 __getval(void) { return __val; }
  262. void __setval(__decfloat32 __x) { __val = __x; }
  263. };
  264. /// 3.2.3 Class decimal64.
  265. class decimal64
  266. {
  267. public:
  268. typedef float __decfloat64 __attribute__((mode(DD)));
  269. // 3.2.3.2 Construct/copy/destroy.
  270. decimal64() : __val(0.e-398dd) {}
  271. // 3.2.3.3 Conversion from floating-point type.
  272. decimal64(decimal32 d32);
  273. explicit decimal64(decimal128 d128);
  274. explicit decimal64(float __r) : __val(__r) {}
  275. explicit decimal64(double __r) : __val(__r) {}
  276. explicit decimal64(long double __r) : __val(__r) {}
  277. // 3.2.3.4 Conversion from integral type.
  278. decimal64(int __z) : __val(__z) {}
  279. decimal64(unsigned int __z) : __val(__z) {}
  280. decimal64(long __z) : __val(__z) {}
  281. decimal64(unsigned long __z) : __val(__z) {}
  282. decimal64(long long __z) : __val(__z) {}
  283. decimal64(unsigned long long __z) : __val(__z) {}
  284. /// Conforming extension: Conversion from scalar decimal type.
  285. decimal64(__decfloat64 __z) : __val(__z) {}
  286. #if __cplusplus >= 201103L
  287. // 3.2.3.5 Conversion to integral type.
  288. // Note: explicit per n3407.
  289. explicit operator long long() const { return (long long)__val; }
  290. #endif
  291. // 3.2.3.6 Increment and decrement operators.
  292. decimal64& operator++()
  293. {
  294. __val += 1;
  295. return *this;
  296. }
  297. decimal64 operator++(int)
  298. {
  299. decimal64 __tmp = *this;
  300. __val += 1;
  301. return __tmp;
  302. }
  303. decimal64& operator--()
  304. {
  305. __val -= 1;
  306. return *this;
  307. }
  308. decimal64 operator--(int)
  309. {
  310. decimal64 __tmp = *this;
  311. __val -= 1;
  312. return __tmp;
  313. }
  314. // 3.2.3.7 Compound assignment.
  315. #define _DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT(_Op) \
  316. decimal64& operator _Op(decimal32 __rhs); \
  317. decimal64& operator _Op(decimal64 __rhs); \
  318. decimal64& operator _Op(decimal128 __rhs); \
  319. decimal64& operator _Op(int __rhs); \
  320. decimal64& operator _Op(unsigned int __rhs); \
  321. decimal64& operator _Op(long __rhs); \
  322. decimal64& operator _Op(unsigned long __rhs); \
  323. decimal64& operator _Op(long long __rhs); \
  324. decimal64& operator _Op(unsigned long long __rhs);
  325. _DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT(+=)
  326. _DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT(-=)
  327. _DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT(*=)
  328. _DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT(/=)
  329. #undef _DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT
  330. private:
  331. __decfloat64 __val;
  332. public:
  333. __decfloat64 __getval(void) { return __val; }
  334. void __setval(__decfloat64 __x) { __val = __x; }
  335. };
  336. /// 3.2.4 Class decimal128.
  337. class decimal128
  338. {
  339. public:
  340. typedef float __decfloat128 __attribute__((mode(TD)));
  341. // 3.2.4.2 Construct/copy/destroy.
  342. decimal128() : __val(0.e-6176DL) {}
  343. // 3.2.4.3 Conversion from floating-point type.
  344. decimal128(decimal32 d32);
  345. decimal128(decimal64 d64);
  346. explicit decimal128(float __r) : __val(__r) {}
  347. explicit decimal128(double __r) : __val(__r) {}
  348. explicit decimal128(long double __r) : __val(__r) {}
  349. // 3.2.4.4 Conversion from integral type.
  350. decimal128(int __z) : __val(__z) {}
  351. decimal128(unsigned int __z) : __val(__z) {}
  352. decimal128(long __z) : __val(__z) {}
  353. decimal128(unsigned long __z) : __val(__z) {}
  354. decimal128(long long __z) : __val(__z) {}
  355. decimal128(unsigned long long __z) : __val(__z) {}
  356. /// Conforming extension: Conversion from scalar decimal type.
  357. decimal128(__decfloat128 __z) : __val(__z) {}
  358. #if __cplusplus >= 201103L
  359. // 3.2.4.5 Conversion to integral type.
  360. // Note: explicit per n3407.
  361. explicit operator long long() const { return (long long)__val; }
  362. #endif
  363. // 3.2.4.6 Increment and decrement operators.
  364. decimal128& operator++()
  365. {
  366. __val += 1;
  367. return *this;
  368. }
  369. decimal128 operator++(int)
  370. {
  371. decimal128 __tmp = *this;
  372. __val += 1;
  373. return __tmp;
  374. }
  375. decimal128& operator--()
  376. {
  377. __val -= 1;
  378. return *this;
  379. }
  380. decimal128 operator--(int)
  381. {
  382. decimal128 __tmp = *this;
  383. __val -= 1;
  384. return __tmp;
  385. }
  386. // 3.2.4.7 Compound assignment.
  387. #define _DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT(_Op) \
  388. decimal128& operator _Op(decimal32 __rhs); \
  389. decimal128& operator _Op(decimal64 __rhs); \
  390. decimal128& operator _Op(decimal128 __rhs); \
  391. decimal128& operator _Op(int __rhs); \
  392. decimal128& operator _Op(unsigned int __rhs); \
  393. decimal128& operator _Op(long __rhs); \
  394. decimal128& operator _Op(unsigned long __rhs); \
  395. decimal128& operator _Op(long long __rhs); \
  396. decimal128& operator _Op(unsigned long long __rhs);
  397. _DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT(+=)
  398. _DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT(-=)
  399. _DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT(*=)
  400. _DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT(/=)
  401. #undef _DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT
  402. private:
  403. __decfloat128 __val;
  404. public:
  405. __decfloat128 __getval(void) { return __val; }
  406. void __setval(__decfloat128 __x) { __val = __x; }
  407. };
  408. #define _GLIBCXX_USE_DECIMAL_ 1
  409. } // namespace decimal
  410. // @} group decimal
  411. _GLIBCXX_END_NAMESPACE_VERSION
  412. } // namespace std
  413. #include <decimal/decimal.h>
  414. #endif /* _GLIBCXX_DECIMAL */