8#ifndef INCLUDED_BDLDFP_DECIMALIMPUTIL_INTELDFP
9#define INCLUDED_BDLDFP_DECIMALIMPUTIL_INTELDFP
65#include <bdlscm_version.h>
70#ifdef BDLDFP_DECIMALPLATFORM_INTELDFP
77#include <bsl_locale.h>
78#include <bsl_cstring.h>
79#include <bsl_c_errno.h>
91struct DecimalImpUtil_IntelDfp {
94 struct ValueType32 { BID_UINT32 d_raw; };
95 struct ValueType64 { BID_UINT64 d_raw; };
96 struct ValueType128 { BID_UINT128 d_raw; };
101 k_STATUS_INEXACT = BID_INEXACT_EXCEPTION,
102 k_STATUS_UNDERFLOW = BID_UNDERFLOW_EXCEPTION,
103 k_STATUS_OVERFLOW = BID_OVERFLOW_EXCEPTION
116 static void setErrno(_IDEC_flags flags);
123 static ValueType32 int32ToDecimal32 (
int value);
124 static ValueType32 uint32ToDecimal32 (
unsigned int value);
125 static ValueType32 int64ToDecimal32 (
long long int value);
141 static ValueType32 uint64ToDecimal32 (
unsigned long long int value);
145 static ValueType64 int32ToDecimal64 (
int value);
146 static ValueType64 uint32ToDecimal64 (
unsigned int value);
147 static ValueType64 int64ToDecimal64 (
long long int value);
163 static ValueType64 uint64ToDecimal64 (
unsigned long long int value);
167 static ValueType128 int32ToDecimal128(
int value);
168 static ValueType128 uint32ToDecimal128(
unsigned int value);
169 static ValueType128 int64ToDecimal128(
long long int value);
185 static ValueType128 uint64ToDecimal128(
unsigned long long int value);
194 static ValueType32 add(ValueType32 lhs, ValueType32 rhs);
195 static ValueType64 add(ValueType64 lhs, ValueType64 rhs);
211 static ValueType128 add(ValueType128 lhs, ValueType128 rhs);
218 static ValueType32 subtract(ValueType32 lhs, ValueType32 rhs);
219 static ValueType64 subtract(ValueType64 lhs, ValueType64 rhs);
236 static ValueType128 subtract(ValueType128 lhs, ValueType128 rhs);
243 static ValueType32 multiply(ValueType32 lhs, ValueType32 rhs);
244 static ValueType64 multiply(ValueType64 lhs, ValueType64 rhs);
269 static ValueType128 multiply(ValueType128 lhs, ValueType128 rhs);
276 static ValueType32 divide(ValueType32 lhs, ValueType32 rhs);
277 static ValueType64 divide(ValueType64 lhs, ValueType64 rhs);
306 static ValueType128 divide(ValueType128 lhs, ValueType128 rhs);
310 static ValueType32 negate(ValueType32 value);
311 static ValueType64 negate(ValueType64 value);
316 static ValueType128 negate(ValueType128 value);
338 static bool less(ValueType32 lhs, ValueType32 rhs);
339 static bool less(ValueType64 lhs, ValueType64 rhs);
342 static bool less(ValueType128 lhs, ValueType128 rhs);
362 static bool greater(ValueType32 lhs, ValueType32 rhs);
363 static bool greater(ValueType64 lhs, ValueType64 rhs);
366 static bool greater(ValueType128 lhs, ValueType128 rhs);
385 static bool lessEqual(ValueType32 lhs, ValueType32 rhs);
386 static bool lessEqual(ValueType64 lhs, ValueType64 rhs);
389 static bool lessEqual(ValueType128 lhs, ValueType128 rhs);
409 static bool greaterEqual(ValueType32 lhs, ValueType32 rhs);
410 static bool greaterEqual(ValueType64 lhs, ValueType64 rhs);
413 static bool greaterEqual(ValueType128 lhs, ValueType128 rhs);
428 static bool equal(ValueType32 lhs, ValueType32 rhs);
429 static bool equal(ValueType64 lhs, ValueType64 rhs);
432 static bool equal(ValueType128 lhs, ValueType128 rhs);
447 static bool notEqual(ValueType32 lhs, ValueType32 rhs);
448 static bool notEqual(ValueType64 lhs, ValueType64 rhs);
451 static bool notEqual(ValueType128 lhs, ValueType128 rhs);
455 static ValueType32 convertToDecimal32 (
const ValueType64& input);
456 static ValueType32 convertToDecimal32 (
const ValueType128& input);
457 static ValueType64 convertToDecimal64 (
const ValueType32& input);
458 static ValueType64 convertToDecimal64 (
const ValueType128& input);
463 static ValueType128 convertToDecimal128(
const ValueType32& input);
480 static ValueType128 convertToDecimal128(
const ValueType64& input);
488 static ValueType32 binaryToDecimal32(
float value);
509 static ValueType32 binaryToDecimal32(
double value);
515 static ValueType64 binaryToDecimal64(
float value);
526 static ValueType64 binaryToDecimal64(
double value);
532 static ValueType128 binaryToDecimal128(
float value);
543 static ValueType128 binaryToDecimal128(
double value);
551 static ValueType32 makeDecimalRaw32(
int significand,
int exponent);
553 static ValueType64 makeDecimalRaw64(
unsigned long long int significand,
555 static ValueType64 makeDecimalRaw64(
long long int significand,
557 static ValueType64 makeDecimalRaw64(
unsigned int significand,
564 static ValueType64 makeDecimalRaw64(
int significand,
567 static ValueType128 makeDecimalRaw128(
unsigned long long int significand,
569 static ValueType128 makeDecimalRaw128(
long long int significand,
571 static ValueType128 makeDecimalRaw128(
unsigned int significand,
577 static ValueType128 makeDecimalRaw128(
int significand,
582 static ValueType32 scaleB(ValueType32 value,
int exponent);
583 static ValueType64 scaleB(ValueType64 value,
int exponent);
588 static ValueType128 scaleB(ValueType128 value,
int exponent);
608 static ValueType32 parse32 (
const char *
string);
627 static ValueType64 parse64(
const char *
string);
629 static ValueType128 parse128(
const char *
string);
631 static ValueType32 parse32(
const char *
string,
unsigned int *status);
649 static ValueType64 parse64(
const char *
string,
unsigned int *status);
671 static ValueType128 parse128(
const char *
string,
unsigned int *status);
675 static ValueType32 convertDPDtoBID(DecimalStorage::Type32 dpd);
676 static ValueType64 convertDPDtoBID(DecimalStorage::Type64 dpd);
680 static ValueType128 convertDPDtoBID(DecimalStorage::Type128 dpd);
685 static DecimalStorage::Type32 convertBIDtoDPD(ValueType32 value);
686 static DecimalStorage::Type64 convertBIDtoDPD(ValueType64 value);
687 static DecimalStorage::Type128 convertBIDtoDPD(ValueType128 value);
691 static ValueType32 convertFromBID(DecimalStorage::Type32 bid);
692 static ValueType64 convertFromBID(DecimalStorage::Type64 bid);
696 static ValueType128 convertFromBID(DecimalStorage::Type128 bid);
702 DecimalStorage::Type32 convertToBID(ValueType32 value);
704 DecimalStorage::Type64 convertToBID(ValueType64 value);
706 DecimalStorage::Type128 convertToBID(ValueType128 value);
719void DecimalImpUtil_IntelDfp::setErrno(_IDEC_flags flags)
721 if (BID_INVALID_EXCEPTION & flags) {
724 else if (BID_OVERFLOW_EXCEPTION & flags ||
725 BID_UNDERFLOW_EXCEPTION & flags ||
726 BID_ZERO_DIVIDE_EXCEPTION & flags)
737DecimalImpUtil_IntelDfp::ValueType32
738DecimalImpUtil_IntelDfp::int32ToDecimal32(
int value)
740 DecimalImpUtil_IntelDfp::ValueType32 retval;
741 _IDEC_flags flags(0);
742 retval.d_raw = __bid32_from_int32(value, &flags);
747DecimalImpUtil_IntelDfp::ValueType64
748DecimalImpUtil_IntelDfp::int32ToDecimal64(
int value)
750 DecimalImpUtil_IntelDfp::ValueType64 retval;
751 retval.d_raw = __bid64_from_int32(value);
756DecimalImpUtil_IntelDfp::ValueType128
757DecimalImpUtil_IntelDfp::int32ToDecimal128(
int value)
759 DecimalImpUtil_IntelDfp::ValueType128 retval;
760 retval.d_raw = __bid128_from_int32(value);
766DecimalImpUtil_IntelDfp::ValueType32
767DecimalImpUtil_IntelDfp::uint32ToDecimal32(
unsigned int value)
769 DecimalImpUtil_IntelDfp::ValueType32 retval;
770 _IDEC_flags flags(0);
771 retval.d_raw = __bid32_from_uint32(value, &flags);
776DecimalImpUtil_IntelDfp::ValueType64
777DecimalImpUtil_IntelDfp::uint32ToDecimal64(
unsigned int value)
779 DecimalImpUtil_IntelDfp::ValueType64 retval;
780 retval.d_raw = __bid64_from_uint32(value);
785DecimalImpUtil_IntelDfp::ValueType128
786DecimalImpUtil_IntelDfp::uint32ToDecimal128(
unsigned int value)
788 DecimalImpUtil_IntelDfp::ValueType128 retval;
789 retval.d_raw = __bid128_from_uint32(value);
795DecimalImpUtil_IntelDfp::ValueType32
796DecimalImpUtil_IntelDfp::int64ToDecimal32(
long long int value)
798 DecimalImpUtil_IntelDfp::ValueType32 retval;
799 _IDEC_flags flags(0);
800 retval.d_raw = __bid32_from_int64(value, &flags);
805DecimalImpUtil_IntelDfp::ValueType64
806DecimalImpUtil_IntelDfp::int64ToDecimal64(
long long int value)
808 DecimalImpUtil_IntelDfp::ValueType64 retval;
809 _IDEC_flags flags(0);
810 retval.d_raw = __bid64_from_int64(value, &flags);
815DecimalImpUtil_IntelDfp::ValueType128
816DecimalImpUtil_IntelDfp::int64ToDecimal128(
long long int value)
818 DecimalImpUtil_IntelDfp::ValueType128 retval;
819 retval.d_raw = __bid128_from_int64(value);
825DecimalImpUtil_IntelDfp::ValueType32
826DecimalImpUtil_IntelDfp::uint64ToDecimal32(
unsigned long long int value)
828 DecimalImpUtil_IntelDfp::ValueType32 retval;
829 _IDEC_flags flags(0);
830 retval.d_raw = __bid32_from_uint64(value, &flags);
835DecimalImpUtil_IntelDfp::ValueType64
836DecimalImpUtil_IntelDfp::uint64ToDecimal64(
unsigned long long int value)
838 DecimalImpUtil_IntelDfp::ValueType64 retval;
839 _IDEC_flags flags(0);
840 retval.d_raw = __bid64_from_uint64(value, &flags);
845DecimalImpUtil_IntelDfp::ValueType128
846DecimalImpUtil_IntelDfp::uint64ToDecimal128(
unsigned long long int value)
848 DecimalImpUtil_IntelDfp::ValueType128 retval;
849 retval.d_raw = __bid128_from_uint64(value);
858DecimalImpUtil_IntelDfp::ValueType32
859DecimalImpUtil_IntelDfp::add(DecimalImpUtil_IntelDfp::ValueType32 lhs,
860 DecimalImpUtil_IntelDfp::ValueType32 rhs)
862 DecimalImpUtil_IntelDfp::ValueType32 retval;
863 _IDEC_flags flags(0);
864 retval.d_raw = __bid32_add(lhs.d_raw, rhs.d_raw, &flags);
870DecimalImpUtil_IntelDfp::ValueType64
871DecimalImpUtil_IntelDfp::add(DecimalImpUtil_IntelDfp::ValueType64 lhs,
872 DecimalImpUtil_IntelDfp::ValueType64 rhs)
874 DecimalImpUtil_IntelDfp::ValueType64 retval;
875 _IDEC_flags flags(0);
876 retval.d_raw = __bid64_add(lhs.d_raw, rhs.d_raw, &flags);
882DecimalImpUtil_IntelDfp::ValueType128
883DecimalImpUtil_IntelDfp::add(DecimalImpUtil_IntelDfp::ValueType128 lhs,
884 DecimalImpUtil_IntelDfp::ValueType128 rhs)
886 DecimalImpUtil_IntelDfp::ValueType128 retval;
887 _IDEC_flags flags(0);
888 retval.d_raw = __bid128_add(lhs.d_raw, rhs.d_raw, &flags);
896DecimalImpUtil_IntelDfp::ValueType32
897DecimalImpUtil_IntelDfp::subtract(DecimalImpUtil_IntelDfp::ValueType32 lhs,
898 DecimalImpUtil_IntelDfp::ValueType32 rhs)
900 DecimalImpUtil_IntelDfp::ValueType32 retval;
901 _IDEC_flags flags(0);
902 retval.d_raw = __bid32_sub(lhs.d_raw, rhs.d_raw, &flags);
908DecimalImpUtil_IntelDfp::ValueType64
909DecimalImpUtil_IntelDfp::subtract(DecimalImpUtil_IntelDfp::ValueType64 lhs,
910 DecimalImpUtil_IntelDfp::ValueType64 rhs)
912 DecimalImpUtil_IntelDfp::ValueType64 retval;
913 _IDEC_flags flags(0);
914 retval.d_raw = __bid64_sub(lhs.d_raw, rhs.d_raw, &flags);
920DecimalImpUtil_IntelDfp::ValueType128
921DecimalImpUtil_IntelDfp::subtract(DecimalImpUtil_IntelDfp::ValueType128 lhs,
922 DecimalImpUtil_IntelDfp::ValueType128 rhs)
924 DecimalImpUtil_IntelDfp::ValueType128 retval;
925 _IDEC_flags flags(0);
926 retval.d_raw = __bid128_sub(lhs.d_raw, rhs.d_raw, &flags);
934DecimalImpUtil_IntelDfp::ValueType32
935DecimalImpUtil_IntelDfp::multiply(DecimalImpUtil_IntelDfp::ValueType32 lhs,
936 DecimalImpUtil_IntelDfp::ValueType32 rhs)
938 DecimalImpUtil_IntelDfp::ValueType32 retval;
939 _IDEC_flags flags(0);
940 retval.d_raw = __bid32_mul(lhs.d_raw, rhs.d_raw, &flags);
946DecimalImpUtil_IntelDfp::ValueType64
947DecimalImpUtil_IntelDfp::multiply(DecimalImpUtil_IntelDfp::ValueType64 lhs,
948 DecimalImpUtil_IntelDfp::ValueType64 rhs)
950 DecimalImpUtil_IntelDfp::ValueType64 retval;
951 _IDEC_flags flags(0);
952 retval.d_raw = __bid64_mul(lhs.d_raw, rhs.d_raw, &flags);
958DecimalImpUtil_IntelDfp::ValueType128
959DecimalImpUtil_IntelDfp::multiply(DecimalImpUtil_IntelDfp::ValueType128 lhs,
960 DecimalImpUtil_IntelDfp::ValueType128 rhs)
962 DecimalImpUtil_IntelDfp::ValueType128 retval;
963 _IDEC_flags flags(0);
964 retval.d_raw = __bid128_mul(lhs.d_raw, rhs.d_raw, &flags);
972DecimalImpUtil_IntelDfp::ValueType32
973DecimalImpUtil_IntelDfp::divide(DecimalImpUtil_IntelDfp::ValueType32 lhs,
974 DecimalImpUtil_IntelDfp::ValueType32 rhs)
976 DecimalImpUtil_IntelDfp::ValueType32 retval;
977 _IDEC_flags flags(0);
978 retval.d_raw = __bid32_div(lhs.d_raw, rhs.d_raw, &flags);
984DecimalImpUtil_IntelDfp::ValueType64
985DecimalImpUtil_IntelDfp::divide(DecimalImpUtil_IntelDfp::ValueType64 lhs,
986 DecimalImpUtil_IntelDfp::ValueType64 rhs)
988 DecimalImpUtil_IntelDfp::ValueType64 retval;
989 _IDEC_flags flags(0);
990 retval.d_raw = __bid64_div(lhs.d_raw, rhs.d_raw, &flags);
996DecimalImpUtil_IntelDfp::ValueType128
997DecimalImpUtil_IntelDfp::divide(DecimalImpUtil_IntelDfp::ValueType128 lhs,
998 DecimalImpUtil_IntelDfp::ValueType128 rhs)
1000 DecimalImpUtil_IntelDfp::ValueType128 retval;
1001 _IDEC_flags flags(0);
1002 retval.d_raw = __bid128_div(lhs.d_raw, rhs.d_raw, &flags);
1010DecimalImpUtil_IntelDfp::ValueType32
1011DecimalImpUtil_IntelDfp::negate(DecimalImpUtil_IntelDfp::ValueType32 value)
1013 DecimalImpUtil_IntelDfp::ValueType32 retval;
1014 retval.d_raw = __bid32_negate(value.d_raw);
1019DecimalImpUtil_IntelDfp::ValueType64
1020DecimalImpUtil_IntelDfp::negate(DecimalImpUtil_IntelDfp::ValueType64 value)
1022 DecimalImpUtil_IntelDfp::ValueType64 retval;
1023 retval.d_raw = __bid64_negate(value.d_raw);
1028DecimalImpUtil_IntelDfp::ValueType128
1029DecimalImpUtil_IntelDfp::negate(DecimalImpUtil_IntelDfp::ValueType128 value)
1031 DecimalImpUtil_IntelDfp::ValueType128 retval;
1032 retval.d_raw = __bid128_negate(value.d_raw);
1042DecimalImpUtil_IntelDfp::less(DecimalImpUtil_IntelDfp::ValueType32 lhs,
1043 DecimalImpUtil_IntelDfp::ValueType32 rhs)
1045 _IDEC_flags flags(0);
1046 bool res = __bid32_quiet_less(lhs.d_raw, rhs.d_raw, &flags);
1053DecimalImpUtil_IntelDfp::less(DecimalImpUtil_IntelDfp::ValueType64 lhs,
1054 DecimalImpUtil_IntelDfp::ValueType64 rhs)
1056 _IDEC_flags flags(0);
1057 bool res = __bid64_quiet_less(lhs.d_raw, rhs.d_raw, &flags);
1064DecimalImpUtil_IntelDfp::less(DecimalImpUtil_IntelDfp::ValueType128 lhs,
1065 DecimalImpUtil_IntelDfp::ValueType128 rhs)
1067 _IDEC_flags flags(0);
1068 bool res = __bid128_quiet_less(lhs.d_raw, rhs.d_raw, &flags);
1077DecimalImpUtil_IntelDfp::greater(DecimalImpUtil_IntelDfp::ValueType32 lhs,
1078 DecimalImpUtil_IntelDfp::ValueType32 rhs)
1080 _IDEC_flags flags(0);
1081 bool res = __bid32_quiet_greater(lhs.d_raw, rhs.d_raw, &flags);
1087bool DecimalImpUtil_IntelDfp::greater(DecimalImpUtil_IntelDfp::ValueType64 lhs,
1088 DecimalImpUtil_IntelDfp::ValueType64 rhs)
1090 _IDEC_flags flags(0);
1091 bool res = __bid64_quiet_greater(lhs.d_raw, rhs.d_raw, &flags);
1098DecimalImpUtil_IntelDfp::greater(DecimalImpUtil_IntelDfp::ValueType128 lhs,
1099 DecimalImpUtil_IntelDfp::ValueType128 rhs)
1101 _IDEC_flags flags(0);
1102 bool res = __bid128_quiet_greater(lhs.d_raw, rhs.d_raw, &flags);
1111DecimalImpUtil_IntelDfp::lessEqual(DecimalImpUtil_IntelDfp::ValueType32 lhs,
1112 DecimalImpUtil_IntelDfp::ValueType32 rhs)
1114 _IDEC_flags flags(0);
1115 bool res = __bid32_quiet_less_equal(lhs.d_raw, rhs.d_raw, &flags);
1122DecimalImpUtil_IntelDfp::lessEqual(DecimalImpUtil_IntelDfp::ValueType64 lhs,
1123 DecimalImpUtil_IntelDfp::ValueType64 rhs)
1125 _IDEC_flags flags(0);
1126 bool res = __bid64_quiet_less_equal(lhs.d_raw, rhs.d_raw, &flags);
1133DecimalImpUtil_IntelDfp::lessEqual(DecimalImpUtil_IntelDfp::ValueType128 lhs,
1134 DecimalImpUtil_IntelDfp::ValueType128 rhs)
1136 _IDEC_flags flags(0);
1137 bool res = __bid128_quiet_less_equal(lhs.d_raw, rhs.d_raw, &flags);
1146DecimalImpUtil_IntelDfp::greaterEqual(DecimalImpUtil_IntelDfp::ValueType32 lhs,
1147 DecimalImpUtil_IntelDfp::ValueType32 rhs)
1149 _IDEC_flags flags(0);
1150 bool res = __bid32_quiet_greater_equal(lhs.d_raw, rhs.d_raw, &flags);
1157DecimalImpUtil_IntelDfp::greaterEqual(DecimalImpUtil_IntelDfp::ValueType64 lhs,
1158 DecimalImpUtil_IntelDfp::ValueType64 rhs)
1160 _IDEC_flags flags(0);
1161 bool res = __bid64_quiet_greater_equal(lhs.d_raw, rhs.d_raw, &flags);
1168DecimalImpUtil_IntelDfp::greaterEqual(
1169 DecimalImpUtil_IntelDfp::ValueType128 lhs,
1170 DecimalImpUtil_IntelDfp::ValueType128 rhs)
1172 _IDEC_flags flags(0);
1173 bool res = __bid128_quiet_greater_equal(lhs.d_raw, rhs.d_raw, &flags);
1182DecimalImpUtil_IntelDfp::equal(DecimalImpUtil_IntelDfp::ValueType32 lhs,
1183 DecimalImpUtil_IntelDfp::ValueType32 rhs)
1185 _IDEC_flags flags(0);
1186 bool res = __bid32_quiet_equal(lhs.d_raw, rhs.d_raw, &flags);
1193DecimalImpUtil_IntelDfp::equal(DecimalImpUtil_IntelDfp::ValueType64 lhs,
1194 DecimalImpUtil_IntelDfp::ValueType64 rhs)
1196 _IDEC_flags flags(0);
1197 bool res = __bid64_quiet_equal(lhs.d_raw, rhs.d_raw, &flags);
1204DecimalImpUtil_IntelDfp::equal(DecimalImpUtil_IntelDfp::ValueType128 lhs,
1205 DecimalImpUtil_IntelDfp::ValueType128 rhs)
1207 _IDEC_flags flags(0);
1208 bool res = __bid128_quiet_equal(lhs.d_raw, rhs.d_raw, &flags);
1217DecimalImpUtil_IntelDfp::notEqual(DecimalImpUtil_IntelDfp::ValueType32 lhs,
1218 DecimalImpUtil_IntelDfp::ValueType32 rhs)
1220 _IDEC_flags flags(0);
1221 bool res = __bid32_quiet_not_equal(lhs.d_raw, rhs.d_raw, &flags);
1228DecimalImpUtil_IntelDfp::notEqual(DecimalImpUtil_IntelDfp::ValueType64 lhs,
1229 DecimalImpUtil_IntelDfp::ValueType64 rhs)
1231 _IDEC_flags flags(0);
1232 bool res = __bid64_quiet_not_equal(lhs.d_raw, rhs.d_raw, &flags);
1239DecimalImpUtil_IntelDfp::notEqual(DecimalImpUtil_IntelDfp::ValueType128 lhs,
1240 DecimalImpUtil_IntelDfp::ValueType128 rhs)
1242 _IDEC_flags flags(0);
1243 bool res = __bid128_quiet_not_equal(lhs.d_raw, rhs.d_raw, &flags);
1251DecimalImpUtil_IntelDfp::ValueType32
1252DecimalImpUtil_IntelDfp::convertToDecimal32(
1253 const DecimalImpUtil_IntelDfp::ValueType64& input)
1255 DecimalImpUtil_IntelDfp::ValueType32 retval;
1256 _IDEC_flags flags(0);
1257 retval.d_raw = __bid64_to_bid32(input.d_raw, &flags);
1263DecimalImpUtil_IntelDfp::ValueType32
1264DecimalImpUtil_IntelDfp::convertToDecimal32(
1265 const DecimalImpUtil_IntelDfp::ValueType128& input)
1267 DecimalImpUtil_IntelDfp::ValueType32 retval;
1268 _IDEC_flags flags(0);
1269 retval.d_raw = __bid128_to_bid32(input.d_raw, &flags);
1275DecimalImpUtil_IntelDfp::ValueType64
1276DecimalImpUtil_IntelDfp::convertToDecimal64(
1277 const DecimalImpUtil_IntelDfp::ValueType32& input)
1279 DecimalImpUtil_IntelDfp::ValueType64 retval;
1280 _IDEC_flags flags(0);
1281 retval.d_raw = __bid32_to_bid64(input.d_raw, &flags);
1287DecimalImpUtil_IntelDfp::ValueType64
1288DecimalImpUtil_IntelDfp::convertToDecimal64(
1289 const DecimalImpUtil_IntelDfp::ValueType128& input)
1291 DecimalImpUtil_IntelDfp::ValueType64 retval;
1292 _IDEC_flags flags(0);
1293 retval.d_raw = __bid128_to_bid64(input.d_raw, &flags);
1299DecimalImpUtil_IntelDfp::ValueType128
1300DecimalImpUtil_IntelDfp::convertToDecimal128(
1301 const DecimalImpUtil_IntelDfp::ValueType32& input)
1303 DecimalImpUtil_IntelDfp::ValueType128 retval;
1304 _IDEC_flags flags(0);
1305 retval.d_raw = __bid32_to_bid128(input.d_raw, &flags);
1311DecimalImpUtil_IntelDfp::ValueType128
1312DecimalImpUtil_IntelDfp::convertToDecimal128(
1313 const DecimalImpUtil_IntelDfp::ValueType64& input)
1315 DecimalImpUtil_IntelDfp::ValueType128 retval;
1316 _IDEC_flags flags(0);
1317 retval.d_raw = __bid64_to_bid128(input.d_raw, &flags);
1325DecimalImpUtil_IntelDfp::ValueType32
1326DecimalImpUtil_IntelDfp::binaryToDecimal32(
float value)
1329 _IDEC_flags flags(0);
1330 result.d_raw = __binary32_to_bid32(value, &flags);
1336DecimalImpUtil_IntelDfp::ValueType32
1337DecimalImpUtil_IntelDfp::binaryToDecimal32(
double value)
1340 _IDEC_flags flags(0);
1341 result.d_raw = __binary64_to_bid32(value, &flags);
1347DecimalImpUtil_IntelDfp::ValueType64
1348DecimalImpUtil_IntelDfp::binaryToDecimal64(
float value)
1351 _IDEC_flags flags(0);
1352 result.d_raw = __binary32_to_bid64(value, &flags);
1358DecimalImpUtil_IntelDfp::ValueType64
1359DecimalImpUtil_IntelDfp::binaryToDecimal64(
double value)
1362 _IDEC_flags flags(0);
1363 result.d_raw = __binary64_to_bid64(value, &flags);
1369DecimalImpUtil_IntelDfp::ValueType128
1370DecimalImpUtil_IntelDfp::binaryToDecimal128(
float value)
1372 ValueType128 result;
1373 _IDEC_flags flags(0);
1374 result.d_raw = __binary32_to_bid128(value, &flags);
1380DecimalImpUtil_IntelDfp::ValueType128
1381DecimalImpUtil_IntelDfp::binaryToDecimal128(
double value)
1383 ValueType128 result;
1384 _IDEC_flags flags(0);
1385 result.d_raw = __binary64_to_bid128(value, &flags);
1393DecimalImpUtil_IntelDfp::ValueType32
1394DecimalImpUtil_IntelDfp::makeDecimalRaw32(
int significand,
1397 DecimalImpUtil_IntelDfp::ValueType32 result;
1398 result = DecimalImpUtil_IntelDfp::int32ToDecimal32(significand);
1399 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1404DecimalImpUtil_IntelDfp::ValueType64
1405DecimalImpUtil_IntelDfp::makeDecimalRaw64(
unsigned long long significand,
1408 DecimalImpUtil_IntelDfp::ValueType64 result;
1409 result = DecimalImpUtil_IntelDfp::uint64ToDecimal64(significand);
1410 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1415DecimalImpUtil_IntelDfp::ValueType64
1416DecimalImpUtil_IntelDfp::makeDecimalRaw64(
long long significand,
1419 DecimalImpUtil_IntelDfp::ValueType64 result;
1420 result = DecimalImpUtil_IntelDfp::int64ToDecimal64(significand);
1421 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1426DecimalImpUtil_IntelDfp::ValueType64
1427DecimalImpUtil_IntelDfp::makeDecimalRaw64(
unsigned int significand,
1430 DecimalImpUtil_IntelDfp::ValueType64 result;
1431 result = DecimalImpUtil_IntelDfp::uint32ToDecimal64(significand);
1432 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1437DecimalImpUtil_IntelDfp::ValueType64
1438DecimalImpUtil_IntelDfp::makeDecimalRaw64(
int significand,
1441 DecimalImpUtil_IntelDfp::ValueType64 result;
1442 result = DecimalImpUtil_IntelDfp::int32ToDecimal64(significand);
1443 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1448DecimalImpUtil_IntelDfp::ValueType128
1449DecimalImpUtil_IntelDfp::makeDecimalRaw128(
unsigned long long significand,
1452 DecimalImpUtil_IntelDfp::ValueType128 result;
1453 result = DecimalImpUtil_IntelDfp::uint64ToDecimal128(significand);
1454 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1459DecimalImpUtil_IntelDfp::ValueType128
1460DecimalImpUtil_IntelDfp::makeDecimalRaw128(
long long significand,
1463 DecimalImpUtil_IntelDfp::ValueType128 result;
1464 result = DecimalImpUtil_IntelDfp::int64ToDecimal128(significand);
1465 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1470DecimalImpUtil_IntelDfp::ValueType128
1471DecimalImpUtil_IntelDfp::makeDecimalRaw128(
unsigned int significand,
1474 DecimalImpUtil_IntelDfp::ValueType128 result;
1475 result = DecimalImpUtil_IntelDfp::uint32ToDecimal128(significand);
1476 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1481DecimalImpUtil_IntelDfp::ValueType128
1482DecimalImpUtil_IntelDfp::makeDecimalRaw128(
int significand,
1485 DecimalImpUtil_IntelDfp::ValueType128 result;
1486 result = DecimalImpUtil_IntelDfp::int32ToDecimal128(significand);
1487 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1494DecimalImpUtil_IntelDfp::ValueType32
1495DecimalImpUtil_IntelDfp::scaleB(DecimalImpUtil_IntelDfp::ValueType32 value,
1498 DecimalImpUtil_IntelDfp::ValueType32 result;
1499 _IDEC_flags flags(0);
1500 result.d_raw = __bid32_scalbn(value.d_raw, exponent, &flags);
1505DecimalImpUtil_IntelDfp::ValueType64
1506DecimalImpUtil_IntelDfp::scaleB(DecimalImpUtil_IntelDfp::ValueType64 value,
1509 DecimalImpUtil_IntelDfp::ValueType64 result;
1510 _IDEC_flags flags(0);
1511 result.d_raw = __bid64_scalbn(value.d_raw, exponent, &flags);
1516DecimalImpUtil_IntelDfp::ValueType128
1517DecimalImpUtil_IntelDfp::scaleB(DecimalImpUtil_IntelDfp::ValueType128 value,
1520 DecimalImpUtil_IntelDfp::ValueType128 result;
1521 _IDEC_flags flags(0);
1522 result.d_raw = __bid128_scalbn(value.d_raw, exponent, &flags);
1529DecimalImpUtil_IntelDfp::ValueType32
1530DecimalImpUtil_IntelDfp::parse32(
const char *
string)
1532 DecimalImpUtil_IntelDfp::ValueType32 result;
1533 _IDEC_flags flags(0);
1536 result.d_raw = __bid32_from_string(
const_cast<char *
>(
string), &flags);
1538 if (BID_OVERFLOW_EXCEPTION & flags ||
1539 BID_UNDERFLOW_EXCEPTION & flags)
1549DecimalImpUtil_IntelDfp::ValueType64
1550DecimalImpUtil_IntelDfp::parse64(
const char *
string)
1552 DecimalImpUtil_IntelDfp::ValueType64 result;
1553 _IDEC_flags flags(0);
1556 result.d_raw = __bid64_from_string(
const_cast<char *
>(
string), &flags);
1558 if (BID_OVERFLOW_EXCEPTION & flags ||
1559 BID_UNDERFLOW_EXCEPTION & flags)
1568DecimalImpUtil_IntelDfp::ValueType128
1569DecimalImpUtil_IntelDfp::parse128(
const char *
string)
1571 DecimalImpUtil_IntelDfp::ValueType128 result;
1572 _IDEC_flags flags(0);
1575 result.d_raw = __bid128_from_string(
const_cast<char *
>(
string), &flags);
1577 if (BID_OVERFLOW_EXCEPTION & flags ||
1578 BID_UNDERFLOW_EXCEPTION & flags)
1588DecimalImpUtil_IntelDfp::ValueType32
1589DecimalImpUtil_IntelDfp::parse32(
const char *
string,
unsigned int *status)
1593 DecimalImpUtil_IntelDfp::ValueType32 result;
1601 result.d_raw = __bid32_from_string(
const_cast<char *
>(
string), status);
1608DecimalImpUtil_IntelDfp::ValueType64
1609DecimalImpUtil_IntelDfp::parse64(
const char *
string,
unsigned int *status)
1613 DecimalImpUtil_IntelDfp::ValueType64 result;
1622 result.d_raw = __bid64_from_string(
const_cast<char *
>(
string), status);
1628DecimalImpUtil_IntelDfp::ValueType128
1629DecimalImpUtil_IntelDfp::parse128(
const char *
string,
unsigned int *status)
1633 DecimalImpUtil_IntelDfp::ValueType128 result;
1641 result.d_raw = __bid128_from_string(
const_cast<char *
>(
string), status);
1648DecimalImpUtil_IntelDfp::ValueType32
1652 bsl::memcpy(&value, &dpd,
sizeof(value));
1655 result.d_raw = __bid_dpd_to_bid32(value.d_raw);
1661DecimalImpUtil_IntelDfp::ValueType64
1665 bsl::memcpy(&value, &dpd,
sizeof(value));
1668 result.d_raw = __bid_dpd_to_bid64(value.d_raw);
1674DecimalImpUtil_IntelDfp::ValueType128
1678 bsl::memcpy(&value, &dpd,
sizeof(value));
1680 ValueType128 result;
1681 result.d_raw = __bid_dpd_to_bid128(value.d_raw);
1688DecimalImpUtil_IntelDfp::convertBIDtoDPD(
1689 DecimalImpUtil_IntelDfp::ValueType32 value)
1692 result.d_raw = __bid_to_dpd32(value.d_raw);
1695 bsl::memcpy(&dpd, &result,
sizeof(dpd));
1702DecimalImpUtil_IntelDfp::convertBIDtoDPD(
1703 DecimalImpUtil_IntelDfp::ValueType64 value)
1706 result.d_raw = __bid_to_dpd64(value.d_raw);
1709 bsl::memcpy(&dpd, &result,
sizeof(dpd));
1716DecimalImpUtil_IntelDfp::convertBIDtoDPD(
1717 DecimalImpUtil_IntelDfp::ValueType128 value)
1719 ValueType128 result;
1720 result.d_raw = __bid_to_dpd128(value.d_raw);
1723 bsl::memcpy(&dpd, &result,
sizeof(dpd));
1730DecimalImpUtil_IntelDfp::ValueType32
1734 bsl::memcpy(&result, &bid,
sizeof(result));
1740DecimalImpUtil_IntelDfp::ValueType64
1744 bsl::memcpy(&result, &bid,
sizeof(result));
1750DecimalImpUtil_IntelDfp::ValueType128
1753 ValueType128 result;
1754 bsl::memcpy(&result, &bid,
sizeof(result));
1761DecimalImpUtil_IntelDfp::convertToBID(
1762 DecimalImpUtil_IntelDfp::ValueType32 value)
1765 bsl::memcpy(&bid, &value,
sizeof(bid));
1772DecimalImpUtil_IntelDfp::convertToBID(
1773 DecimalImpUtil_IntelDfp::ValueType64 value)
1776 bsl::memcpy(&bid, &value,
sizeof(bid));
1783DecimalImpUtil_IntelDfp::convertToBID(
1784 DecimalImpUtil_IntelDfp::ValueType128 value)
1787 bsl::memcpy(&bid, &value,
sizeof(bid));
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:229
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdldfp_decimal.h:712
BID_UINT128 Type128
Definition bdldfp_decimalstorage.h:84
BID_UINT64 Type64
Definition bdldfp_decimalstorage.h:83
BID_UINT32 Type32
Definition bdldfp_decimalstorage.h:82
Definition bslmf_issame.h:146