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>
93struct DecimalImpUtil_IntelDfp {
96 struct ValueType32 { BID_UINT32 d_raw; };
97 struct ValueType64 { BID_UINT64 d_raw; };
98 struct ValueType128 { BID_UINT128 d_raw; };
103 k_STATUS_INEXACT = BID_INEXACT_EXCEPTION,
104 k_STATUS_UNDERFLOW = BID_UNDERFLOW_EXCEPTION,
105 k_STATUS_OVERFLOW = BID_OVERFLOW_EXCEPTION
118 static void setErrno(_IDEC_flags flags);
125 static ValueType32 int32ToDecimal32 (
int value);
126 static ValueType32 uint32ToDecimal32 (
unsigned int value);
127 static ValueType32 int64ToDecimal32 (
long long int value);
143 static ValueType32 uint64ToDecimal32 (
unsigned long long int value);
147 static ValueType64 int32ToDecimal64 (
int value);
148 static ValueType64 uint32ToDecimal64 (
unsigned int value);
149 static ValueType64 int64ToDecimal64 (
long long int value);
165 static ValueType64 uint64ToDecimal64 (
unsigned long long int value);
169 static ValueType128 int32ToDecimal128(
int value);
170 static ValueType128 uint32ToDecimal128(
unsigned int value);
171 static ValueType128 int64ToDecimal128(
long long int value);
187 static ValueType128 uint64ToDecimal128(
unsigned long long int value);
211 static ValueType32 add(ValueType32 lhs, ValueType32 rhs);
212 static ValueType64 add(ValueType64 lhs, ValueType64 rhs);
213 static ValueType128 add(ValueType128 lhs, ValueType128 rhs);
236 static ValueType32 subtract(ValueType32 lhs, ValueType32 rhs);
237 static ValueType64 subtract(ValueType64 lhs, ValueType64 rhs);
238 static ValueType128 subtract(ValueType128 lhs, ValueType128 rhs);
269 static ValueType32 multiply(ValueType32 lhs, ValueType32 rhs);
270 static ValueType64 multiply(ValueType64 lhs, ValueType64 rhs);
271 static ValueType128 multiply(ValueType128 lhs, ValueType128 rhs);
306 static ValueType32 divide(ValueType32 lhs, ValueType32 rhs);
307 static ValueType64 divide(ValueType64 lhs, ValueType64 rhs);
308 static ValueType128 divide(ValueType128 lhs, ValueType128 rhs);
317 static ValueType32 negate(ValueType32 value);
318 static ValueType64 negate(ValueType64 value);
319 static ValueType128 negate(ValueType128 value);
343 static bool less(ValueType32 lhs, ValueType32 rhs);
344 static bool less(ValueType64 lhs, ValueType64 rhs);
345 static bool less(ValueType128 lhs, ValueType128 rhs);
367 static bool greater(ValueType32 lhs, ValueType32 rhs);
368 static bool greater(ValueType64 lhs, ValueType64 rhs);
369 static bool greater(ValueType128 lhs, ValueType128 rhs);
390 static bool lessEqual(ValueType32 lhs, ValueType32 rhs);
391 static bool lessEqual(ValueType64 lhs, ValueType64 rhs);
392 static bool lessEqual(ValueType128 lhs, ValueType128 rhs);
414 static bool greaterEqual(ValueType32 lhs, ValueType32 rhs);
415 static bool greaterEqual(ValueType64 lhs, ValueType64 rhs);
416 static bool greaterEqual(ValueType128 lhs, ValueType128 rhs);
433 static bool equal(ValueType32 lhs, ValueType32 rhs);
434 static bool equal(ValueType64 lhs, ValueType64 rhs);
435 static bool equal(ValueType128 lhs, ValueType128 rhs);
452 static bool notEqual(ValueType32 lhs, ValueType32 rhs);
453 static bool notEqual(ValueType64 lhs, ValueType64 rhs);
454 static bool notEqual(ValueType128 lhs, ValueType128 rhs);
458 static ValueType32 convertToDecimal32 (
const ValueType64& input);
459 static ValueType32 convertToDecimal32 (
const ValueType128& input);
460 static ValueType64 convertToDecimal64 (
const ValueType32& input);
461 static ValueType64 convertToDecimal64 (
const ValueType128& input);
482 static ValueType128 convertToDecimal128(
const ValueType32& input);
483 static ValueType128 convertToDecimal128(
const ValueType64& input);
511 static ValueType32 binaryToDecimal32(
float value);
512 static ValueType32 binaryToDecimal32(
double value);
528 static ValueType64 binaryToDecimal64(
float value);
529 static ValueType64 binaryToDecimal64(
double value);
545 static ValueType128 binaryToDecimal128(
float value);
546 static ValueType128 binaryToDecimal128(
double value);
555 static ValueType32 makeDecimalRaw32(
int significand,
int exponent);
563 static ValueType64 makeDecimalRaw64(
unsigned long long int significand,
565 static ValueType64 makeDecimalRaw64(
long long int significand,
567 static ValueType64 makeDecimalRaw64(
unsigned int significand,
569 static ValueType64 makeDecimalRaw64(
int significand,
577 static ValueType128 makeDecimalRaw128(
unsigned long long int significand,
579 static ValueType128 makeDecimalRaw128(
long long int significand,
581 static ValueType128 makeDecimalRaw128(
unsigned int significand,
583 static ValueType128 makeDecimalRaw128(
int significand,
592 static ValueType32 scaleB(ValueType32 value,
int exponent);
593 static ValueType64 scaleB(ValueType64 value,
int exponent);
594 static ValueType128 scaleB(ValueType128 value,
int exponent);
616 static ValueType32 parse32 (
const char *
string);
637 static ValueType64 parse64(
const char *
string);
658 static ValueType128 parse128(
const char *
string);
660 static ValueType32 parse32(
const char *
string,
unsigned int *status);
661 static ValueType64 parse64(
const char *
string,
unsigned int *status);
686 static ValueType128 parse128(
const char *
string,
unsigned int *status);
693 static ValueType32 convertDPDtoBID(DecimalStorage::Type32 dpd);
694 static ValueType64 convertDPDtoBID(DecimalStorage::Type64 dpd);
695 static ValueType128 convertDPDtoBID(DecimalStorage::Type128 dpd);
700 static DecimalStorage::Type32 convertBIDtoDPD(ValueType32 value);
701 static DecimalStorage::Type64 convertBIDtoDPD(ValueType64 value);
702 static DecimalStorage::Type128 convertBIDtoDPD(ValueType128 value);
709 static ValueType32 convertFromBID(DecimalStorage::Type32 bid);
710 static ValueType64 convertFromBID(DecimalStorage::Type64 bid);
711 static ValueType128 convertFromBID(DecimalStorage::Type128 bid);
717 DecimalStorage::Type32 convertToBID(ValueType32 value);
719 DecimalStorage::Type64 convertToBID(ValueType64 value);
721 DecimalStorage::Type128 convertToBID(ValueType128 value);
734void DecimalImpUtil_IntelDfp::setErrno(_IDEC_flags flags)
736 if (BID_INVALID_EXCEPTION & flags) {
739 else if (BID_OVERFLOW_EXCEPTION & flags ||
740 BID_UNDERFLOW_EXCEPTION & flags ||
741 BID_ZERO_DIVIDE_EXCEPTION & flags)
752DecimalImpUtil_IntelDfp::ValueType32
753DecimalImpUtil_IntelDfp::int32ToDecimal32(
int value)
755 DecimalImpUtil_IntelDfp::ValueType32 retval;
756 _IDEC_flags flags(0);
757 retval.d_raw = __bid32_from_int32(value, &flags);
762DecimalImpUtil_IntelDfp::ValueType64
763DecimalImpUtil_IntelDfp::int32ToDecimal64(
int value)
765 DecimalImpUtil_IntelDfp::ValueType64 retval;
766 retval.d_raw = __bid64_from_int32(value);
771DecimalImpUtil_IntelDfp::ValueType128
772DecimalImpUtil_IntelDfp::int32ToDecimal128(
int value)
774 DecimalImpUtil_IntelDfp::ValueType128 retval;
775 retval.d_raw = __bid128_from_int32(value);
781DecimalImpUtil_IntelDfp::ValueType32
782DecimalImpUtil_IntelDfp::uint32ToDecimal32(
unsigned int value)
784 DecimalImpUtil_IntelDfp::ValueType32 retval;
785 _IDEC_flags flags(0);
786 retval.d_raw = __bid32_from_uint32(value, &flags);
791DecimalImpUtil_IntelDfp::ValueType64
792DecimalImpUtil_IntelDfp::uint32ToDecimal64(
unsigned int value)
794 DecimalImpUtil_IntelDfp::ValueType64 retval;
795 retval.d_raw = __bid64_from_uint32(value);
800DecimalImpUtil_IntelDfp::ValueType128
801DecimalImpUtil_IntelDfp::uint32ToDecimal128(
unsigned int value)
803 DecimalImpUtil_IntelDfp::ValueType128 retval;
804 retval.d_raw = __bid128_from_uint32(value);
810DecimalImpUtil_IntelDfp::ValueType32
811DecimalImpUtil_IntelDfp::int64ToDecimal32(
long long int value)
813 DecimalImpUtil_IntelDfp::ValueType32 retval;
814 _IDEC_flags flags(0);
815 retval.d_raw = __bid32_from_int64(value, &flags);
820DecimalImpUtil_IntelDfp::ValueType64
821DecimalImpUtil_IntelDfp::int64ToDecimal64(
long long int value)
823 DecimalImpUtil_IntelDfp::ValueType64 retval;
824 _IDEC_flags flags(0);
825 retval.d_raw = __bid64_from_int64(value, &flags);
830DecimalImpUtil_IntelDfp::ValueType128
831DecimalImpUtil_IntelDfp::int64ToDecimal128(
long long int value)
833 DecimalImpUtil_IntelDfp::ValueType128 retval;
834 retval.d_raw = __bid128_from_int64(value);
840DecimalImpUtil_IntelDfp::ValueType32
841DecimalImpUtil_IntelDfp::uint64ToDecimal32(
unsigned long long int value)
843 DecimalImpUtil_IntelDfp::ValueType32 retval;
844 _IDEC_flags flags(0);
845 retval.d_raw = __bid32_from_uint64(value, &flags);
850DecimalImpUtil_IntelDfp::ValueType64
851DecimalImpUtil_IntelDfp::uint64ToDecimal64(
unsigned long long int value)
853 DecimalImpUtil_IntelDfp::ValueType64 retval;
854 _IDEC_flags flags(0);
855 retval.d_raw = __bid64_from_uint64(value, &flags);
860DecimalImpUtil_IntelDfp::ValueType128
861DecimalImpUtil_IntelDfp::uint64ToDecimal128(
unsigned long long int value)
863 DecimalImpUtil_IntelDfp::ValueType128 retval;
864 retval.d_raw = __bid128_from_uint64(value);
873DecimalImpUtil_IntelDfp::ValueType32
874DecimalImpUtil_IntelDfp::add(DecimalImpUtil_IntelDfp::ValueType32 lhs,
875 DecimalImpUtil_IntelDfp::ValueType32 rhs)
877 DecimalImpUtil_IntelDfp::ValueType32 retval;
878 _IDEC_flags flags(0);
879 retval.d_raw = __bid32_add(
lhs.d_raw,
rhs.d_raw, &flags);
885DecimalImpUtil_IntelDfp::ValueType64
886DecimalImpUtil_IntelDfp::add(DecimalImpUtil_IntelDfp::ValueType64 lhs,
887 DecimalImpUtil_IntelDfp::ValueType64 rhs)
889 DecimalImpUtil_IntelDfp::ValueType64 retval;
890 _IDEC_flags flags(0);
891 retval.d_raw = __bid64_add(
lhs.d_raw,
rhs.d_raw, &flags);
897DecimalImpUtil_IntelDfp::ValueType128
898DecimalImpUtil_IntelDfp::add(DecimalImpUtil_IntelDfp::ValueType128 lhs,
899 DecimalImpUtil_IntelDfp::ValueType128 rhs)
901 DecimalImpUtil_IntelDfp::ValueType128 retval;
902 _IDEC_flags flags(0);
903 retval.d_raw = __bid128_add(
lhs.d_raw,
rhs.d_raw, &flags);
911DecimalImpUtil_IntelDfp::ValueType32
912DecimalImpUtil_IntelDfp::subtract(DecimalImpUtil_IntelDfp::ValueType32 lhs,
913 DecimalImpUtil_IntelDfp::ValueType32 rhs)
915 DecimalImpUtil_IntelDfp::ValueType32 retval;
916 _IDEC_flags flags(0);
917 retval.d_raw = __bid32_sub(
lhs.d_raw,
rhs.d_raw, &flags);
923DecimalImpUtil_IntelDfp::ValueType64
924DecimalImpUtil_IntelDfp::subtract(DecimalImpUtil_IntelDfp::ValueType64 lhs,
925 DecimalImpUtil_IntelDfp::ValueType64 rhs)
927 DecimalImpUtil_IntelDfp::ValueType64 retval;
928 _IDEC_flags flags(0);
929 retval.d_raw = __bid64_sub(
lhs.d_raw,
rhs.d_raw, &flags);
935DecimalImpUtil_IntelDfp::ValueType128
936DecimalImpUtil_IntelDfp::subtract(DecimalImpUtil_IntelDfp::ValueType128 lhs,
937 DecimalImpUtil_IntelDfp::ValueType128 rhs)
939 DecimalImpUtil_IntelDfp::ValueType128 retval;
940 _IDEC_flags flags(0);
941 retval.d_raw = __bid128_sub(
lhs.d_raw,
rhs.d_raw, &flags);
949DecimalImpUtil_IntelDfp::ValueType32
950DecimalImpUtil_IntelDfp::multiply(DecimalImpUtil_IntelDfp::ValueType32 lhs,
951 DecimalImpUtil_IntelDfp::ValueType32 rhs)
953 DecimalImpUtil_IntelDfp::ValueType32 retval;
954 _IDEC_flags flags(0);
955 retval.d_raw = __bid32_mul(
lhs.d_raw,
rhs.d_raw, &flags);
961DecimalImpUtil_IntelDfp::ValueType64
962DecimalImpUtil_IntelDfp::multiply(DecimalImpUtil_IntelDfp::ValueType64 lhs,
963 DecimalImpUtil_IntelDfp::ValueType64 rhs)
965 DecimalImpUtil_IntelDfp::ValueType64 retval;
966 _IDEC_flags flags(0);
967 retval.d_raw = __bid64_mul(
lhs.d_raw,
rhs.d_raw, &flags);
973DecimalImpUtil_IntelDfp::ValueType128
974DecimalImpUtil_IntelDfp::multiply(DecimalImpUtil_IntelDfp::ValueType128 lhs,
975 DecimalImpUtil_IntelDfp::ValueType128 rhs)
977 DecimalImpUtil_IntelDfp::ValueType128 retval;
978 _IDEC_flags flags(0);
979 retval.d_raw = __bid128_mul(
lhs.d_raw,
rhs.d_raw, &flags);
987DecimalImpUtil_IntelDfp::ValueType32
988DecimalImpUtil_IntelDfp::divide(DecimalImpUtil_IntelDfp::ValueType32 lhs,
989 DecimalImpUtil_IntelDfp::ValueType32 rhs)
991 DecimalImpUtil_IntelDfp::ValueType32 retval;
992 _IDEC_flags flags(0);
993 retval.d_raw = __bid32_div(
lhs.d_raw,
rhs.d_raw, &flags);
999DecimalImpUtil_IntelDfp::ValueType64
1000DecimalImpUtil_IntelDfp::divide(DecimalImpUtil_IntelDfp::ValueType64 lhs,
1001 DecimalImpUtil_IntelDfp::ValueType64 rhs)
1003 DecimalImpUtil_IntelDfp::ValueType64 retval;
1004 _IDEC_flags flags(0);
1005 retval.d_raw = __bid64_div(
lhs.d_raw,
rhs.d_raw, &flags);
1011DecimalImpUtil_IntelDfp::ValueType128
1012DecimalImpUtil_IntelDfp::divide(DecimalImpUtil_IntelDfp::ValueType128 lhs,
1013 DecimalImpUtil_IntelDfp::ValueType128 rhs)
1015 DecimalImpUtil_IntelDfp::ValueType128 retval;
1016 _IDEC_flags flags(0);
1017 retval.d_raw = __bid128_div(
lhs.d_raw,
rhs.d_raw, &flags);
1025DecimalImpUtil_IntelDfp::ValueType32
1026DecimalImpUtil_IntelDfp::negate(DecimalImpUtil_IntelDfp::ValueType32 value)
1028 DecimalImpUtil_IntelDfp::ValueType32 retval;
1029 retval.d_raw = __bid32_negate(value.d_raw);
1034DecimalImpUtil_IntelDfp::ValueType64
1035DecimalImpUtil_IntelDfp::negate(DecimalImpUtil_IntelDfp::ValueType64 value)
1037 DecimalImpUtil_IntelDfp::ValueType64 retval;
1038 retval.d_raw = __bid64_negate(value.d_raw);
1043DecimalImpUtil_IntelDfp::ValueType128
1044DecimalImpUtil_IntelDfp::negate(DecimalImpUtil_IntelDfp::ValueType128 value)
1046 DecimalImpUtil_IntelDfp::ValueType128 retval;
1047 retval.d_raw = __bid128_negate(value.d_raw);
1057DecimalImpUtil_IntelDfp::less(DecimalImpUtil_IntelDfp::ValueType32 lhs,
1058 DecimalImpUtil_IntelDfp::ValueType32 rhs)
1060 _IDEC_flags flags(0);
1061 bool res = __bid32_quiet_less(
lhs.d_raw,
rhs.d_raw, &flags);
1068DecimalImpUtil_IntelDfp::less(DecimalImpUtil_IntelDfp::ValueType64 lhs,
1069 DecimalImpUtil_IntelDfp::ValueType64 rhs)
1071 _IDEC_flags flags(0);
1072 bool res = __bid64_quiet_less(
lhs.d_raw,
rhs.d_raw, &flags);
1079DecimalImpUtil_IntelDfp::less(DecimalImpUtil_IntelDfp::ValueType128 lhs,
1080 DecimalImpUtil_IntelDfp::ValueType128 rhs)
1082 _IDEC_flags flags(0);
1083 bool res = __bid128_quiet_less(
lhs.d_raw,
rhs.d_raw, &flags);
1092DecimalImpUtil_IntelDfp::greater(DecimalImpUtil_IntelDfp::ValueType32 lhs,
1093 DecimalImpUtil_IntelDfp::ValueType32 rhs)
1095 _IDEC_flags flags(0);
1096 bool res = __bid32_quiet_greater(
lhs.d_raw,
rhs.d_raw, &flags);
1102bool DecimalImpUtil_IntelDfp::greater(DecimalImpUtil_IntelDfp::ValueType64 lhs,
1103 DecimalImpUtil_IntelDfp::ValueType64 rhs)
1105 _IDEC_flags flags(0);
1106 bool res = __bid64_quiet_greater(
lhs.d_raw,
rhs.d_raw, &flags);
1113DecimalImpUtil_IntelDfp::greater(DecimalImpUtil_IntelDfp::ValueType128 lhs,
1114 DecimalImpUtil_IntelDfp::ValueType128 rhs)
1116 _IDEC_flags flags(0);
1117 bool res = __bid128_quiet_greater(
lhs.d_raw,
rhs.d_raw, &flags);
1126DecimalImpUtil_IntelDfp::lessEqual(DecimalImpUtil_IntelDfp::ValueType32 lhs,
1127 DecimalImpUtil_IntelDfp::ValueType32 rhs)
1129 _IDEC_flags flags(0);
1130 bool res = __bid32_quiet_less_equal(
lhs.d_raw,
rhs.d_raw, &flags);
1137DecimalImpUtil_IntelDfp::lessEqual(DecimalImpUtil_IntelDfp::ValueType64 lhs,
1138 DecimalImpUtil_IntelDfp::ValueType64 rhs)
1140 _IDEC_flags flags(0);
1141 bool res = __bid64_quiet_less_equal(
lhs.d_raw,
rhs.d_raw, &flags);
1148DecimalImpUtil_IntelDfp::lessEqual(DecimalImpUtil_IntelDfp::ValueType128 lhs,
1149 DecimalImpUtil_IntelDfp::ValueType128 rhs)
1151 _IDEC_flags flags(0);
1152 bool res = __bid128_quiet_less_equal(
lhs.d_raw,
rhs.d_raw, &flags);
1161DecimalImpUtil_IntelDfp::greaterEqual(DecimalImpUtil_IntelDfp::ValueType32 lhs,
1162 DecimalImpUtil_IntelDfp::ValueType32 rhs)
1164 _IDEC_flags flags(0);
1165 bool res = __bid32_quiet_greater_equal(
lhs.d_raw,
rhs.d_raw, &flags);
1172DecimalImpUtil_IntelDfp::greaterEqual(DecimalImpUtil_IntelDfp::ValueType64 lhs,
1173 DecimalImpUtil_IntelDfp::ValueType64 rhs)
1175 _IDEC_flags flags(0);
1176 bool res = __bid64_quiet_greater_equal(
lhs.d_raw,
rhs.d_raw, &flags);
1183DecimalImpUtil_IntelDfp::greaterEqual(
1184 DecimalImpUtil_IntelDfp::ValueType128 lhs,
1185 DecimalImpUtil_IntelDfp::ValueType128 rhs)
1187 _IDEC_flags flags(0);
1188 bool res = __bid128_quiet_greater_equal(
lhs.d_raw,
rhs.d_raw, &flags);
1197DecimalImpUtil_IntelDfp::equal(DecimalImpUtil_IntelDfp::ValueType32 lhs,
1198 DecimalImpUtil_IntelDfp::ValueType32 rhs)
1200 _IDEC_flags flags(0);
1201 bool res = __bid32_quiet_equal(
lhs.d_raw,
rhs.d_raw, &flags);
1208DecimalImpUtil_IntelDfp::equal(DecimalImpUtil_IntelDfp::ValueType64 lhs,
1209 DecimalImpUtil_IntelDfp::ValueType64 rhs)
1211 _IDEC_flags flags(0);
1212 bool res = __bid64_quiet_equal(
lhs.d_raw,
rhs.d_raw, &flags);
1219DecimalImpUtil_IntelDfp::equal(DecimalImpUtil_IntelDfp::ValueType128 lhs,
1220 DecimalImpUtil_IntelDfp::ValueType128 rhs)
1222 _IDEC_flags flags(0);
1223 bool res = __bid128_quiet_equal(
lhs.d_raw,
rhs.d_raw, &flags);
1232DecimalImpUtil_IntelDfp::notEqual(DecimalImpUtil_IntelDfp::ValueType32 lhs,
1233 DecimalImpUtil_IntelDfp::ValueType32 rhs)
1235 _IDEC_flags flags(0);
1236 bool res = __bid32_quiet_not_equal(
lhs.d_raw,
rhs.d_raw, &flags);
1243DecimalImpUtil_IntelDfp::notEqual(DecimalImpUtil_IntelDfp::ValueType64 lhs,
1244 DecimalImpUtil_IntelDfp::ValueType64 rhs)
1246 _IDEC_flags flags(0);
1247 bool res = __bid64_quiet_not_equal(
lhs.d_raw,
rhs.d_raw, &flags);
1254DecimalImpUtil_IntelDfp::notEqual(DecimalImpUtil_IntelDfp::ValueType128 lhs,
1255 DecimalImpUtil_IntelDfp::ValueType128 rhs)
1257 _IDEC_flags flags(0);
1258 bool res = __bid128_quiet_not_equal(
lhs.d_raw,
rhs.d_raw, &flags);
1266DecimalImpUtil_IntelDfp::ValueType32
1267DecimalImpUtil_IntelDfp::convertToDecimal32(
1268 const DecimalImpUtil_IntelDfp::ValueType64& input)
1270 DecimalImpUtil_IntelDfp::ValueType32 retval;
1271 _IDEC_flags flags(0);
1272 retval.d_raw = __bid64_to_bid32(input.d_raw, &flags);
1278DecimalImpUtil_IntelDfp::ValueType32
1279DecimalImpUtil_IntelDfp::convertToDecimal32(
1280 const DecimalImpUtil_IntelDfp::ValueType128& input)
1282 DecimalImpUtil_IntelDfp::ValueType32 retval;
1283 _IDEC_flags flags(0);
1284 retval.d_raw = __bid128_to_bid32(input.d_raw, &flags);
1290DecimalImpUtil_IntelDfp::ValueType64
1291DecimalImpUtil_IntelDfp::convertToDecimal64(
1292 const DecimalImpUtil_IntelDfp::ValueType32& input)
1294 DecimalImpUtil_IntelDfp::ValueType64 retval;
1295 _IDEC_flags flags(0);
1296 retval.d_raw = __bid32_to_bid64(input.d_raw, &flags);
1302DecimalImpUtil_IntelDfp::ValueType64
1303DecimalImpUtil_IntelDfp::convertToDecimal64(
1304 const DecimalImpUtil_IntelDfp::ValueType128& input)
1306 DecimalImpUtil_IntelDfp::ValueType64 retval;
1307 _IDEC_flags flags(0);
1308 retval.d_raw = __bid128_to_bid64(input.d_raw, &flags);
1314DecimalImpUtil_IntelDfp::ValueType128
1315DecimalImpUtil_IntelDfp::convertToDecimal128(
1316 const DecimalImpUtil_IntelDfp::ValueType32& input)
1318 DecimalImpUtil_IntelDfp::ValueType128 retval;
1319 _IDEC_flags flags(0);
1320 retval.d_raw = __bid32_to_bid128(input.d_raw, &flags);
1326DecimalImpUtil_IntelDfp::ValueType128
1327DecimalImpUtil_IntelDfp::convertToDecimal128(
1328 const DecimalImpUtil_IntelDfp::ValueType64& input)
1330 DecimalImpUtil_IntelDfp::ValueType128 retval;
1331 _IDEC_flags flags(0);
1332 retval.d_raw = __bid64_to_bid128(input.d_raw, &flags);
1340DecimalImpUtil_IntelDfp::ValueType32
1341DecimalImpUtil_IntelDfp::binaryToDecimal32(
float value)
1344 _IDEC_flags flags(0);
1345 result.d_raw = __binary32_to_bid32(value, &flags);
1351DecimalImpUtil_IntelDfp::ValueType32
1352DecimalImpUtil_IntelDfp::binaryToDecimal32(
double value)
1355 _IDEC_flags flags(0);
1356 result.d_raw = __binary64_to_bid32(value, &flags);
1362DecimalImpUtil_IntelDfp::ValueType64
1363DecimalImpUtil_IntelDfp::binaryToDecimal64(
float value)
1366 _IDEC_flags flags(0);
1367 result.d_raw = __binary32_to_bid64(value, &flags);
1373DecimalImpUtil_IntelDfp::ValueType64
1374DecimalImpUtil_IntelDfp::binaryToDecimal64(
double value)
1377 _IDEC_flags flags(0);
1378 result.d_raw = __binary64_to_bid64(value, &flags);
1384DecimalImpUtil_IntelDfp::ValueType128
1385DecimalImpUtil_IntelDfp::binaryToDecimal128(
float value)
1387 ValueType128 result;
1388 _IDEC_flags flags(0);
1389 result.d_raw = __binary32_to_bid128(value, &flags);
1395DecimalImpUtil_IntelDfp::ValueType128
1396DecimalImpUtil_IntelDfp::binaryToDecimal128(
double value)
1398 ValueType128 result;
1399 _IDEC_flags flags(0);
1400 result.d_raw = __binary64_to_bid128(value, &flags);
1408DecimalImpUtil_IntelDfp::ValueType32
1409DecimalImpUtil_IntelDfp::makeDecimalRaw32(
int significand,
1412 DecimalImpUtil_IntelDfp::ValueType32 result;
1413 result = DecimalImpUtil_IntelDfp::int32ToDecimal32(significand);
1414 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1419DecimalImpUtil_IntelDfp::ValueType64
1420DecimalImpUtil_IntelDfp::makeDecimalRaw64(
unsigned long long significand,
1423 DecimalImpUtil_IntelDfp::ValueType64 result;
1424 result = DecimalImpUtil_IntelDfp::uint64ToDecimal64(significand);
1425 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1430DecimalImpUtil_IntelDfp::ValueType64
1431DecimalImpUtil_IntelDfp::makeDecimalRaw64(
long long significand,
1434 DecimalImpUtil_IntelDfp::ValueType64 result;
1435 result = DecimalImpUtil_IntelDfp::int64ToDecimal64(significand);
1436 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1441DecimalImpUtil_IntelDfp::ValueType64
1442DecimalImpUtil_IntelDfp::makeDecimalRaw64(
unsigned int significand,
1445 DecimalImpUtil_IntelDfp::ValueType64 result;
1446 result = DecimalImpUtil_IntelDfp::uint32ToDecimal64(significand);
1447 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1452DecimalImpUtil_IntelDfp::ValueType64
1453DecimalImpUtil_IntelDfp::makeDecimalRaw64(
int significand,
1456 DecimalImpUtil_IntelDfp::ValueType64 result;
1457 result = DecimalImpUtil_IntelDfp::int32ToDecimal64(significand);
1458 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1463DecimalImpUtil_IntelDfp::ValueType128
1464DecimalImpUtil_IntelDfp::makeDecimalRaw128(
unsigned long long significand,
1467 DecimalImpUtil_IntelDfp::ValueType128 result;
1468 result = DecimalImpUtil_IntelDfp::uint64ToDecimal128(significand);
1469 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1474DecimalImpUtil_IntelDfp::ValueType128
1475DecimalImpUtil_IntelDfp::makeDecimalRaw128(
long long significand,
1478 DecimalImpUtil_IntelDfp::ValueType128 result;
1479 result = DecimalImpUtil_IntelDfp::int64ToDecimal128(significand);
1480 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1485DecimalImpUtil_IntelDfp::ValueType128
1486DecimalImpUtil_IntelDfp::makeDecimalRaw128(
unsigned int significand,
1489 DecimalImpUtil_IntelDfp::ValueType128 result;
1490 result = DecimalImpUtil_IntelDfp::uint32ToDecimal128(significand);
1491 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1496DecimalImpUtil_IntelDfp::ValueType128
1497DecimalImpUtil_IntelDfp::makeDecimalRaw128(
int significand,
1500 DecimalImpUtil_IntelDfp::ValueType128 result;
1501 result = DecimalImpUtil_IntelDfp::int32ToDecimal128(significand);
1502 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1509DecimalImpUtil_IntelDfp::ValueType32
1510DecimalImpUtil_IntelDfp::scaleB(DecimalImpUtil_IntelDfp::ValueType32 value,
1513 DecimalImpUtil_IntelDfp::ValueType32 result;
1514 _IDEC_flags flags(0);
1515 result.d_raw = __bid32_scalbn(value.d_raw, exponent, &flags);
1520DecimalImpUtil_IntelDfp::ValueType64
1521DecimalImpUtil_IntelDfp::scaleB(DecimalImpUtil_IntelDfp::ValueType64 value,
1524 DecimalImpUtil_IntelDfp::ValueType64 result;
1525 _IDEC_flags flags(0);
1526 result.d_raw = __bid64_scalbn(value.d_raw, exponent, &flags);
1531DecimalImpUtil_IntelDfp::ValueType128
1532DecimalImpUtil_IntelDfp::scaleB(DecimalImpUtil_IntelDfp::ValueType128 value,
1535 DecimalImpUtil_IntelDfp::ValueType128 result;
1536 _IDEC_flags flags(0);
1537 result.d_raw = __bid128_scalbn(value.d_raw, exponent, &flags);
1544DecimalImpUtil_IntelDfp::ValueType32
1545DecimalImpUtil_IntelDfp::parse32(
const char *
string)
1547 DecimalImpUtil_IntelDfp::ValueType32 result;
1548 _IDEC_flags flags(0);
1551 result.d_raw = __bid32_from_string(
const_cast<char *
>(
string), &flags);
1553 if (BID_OVERFLOW_EXCEPTION & flags ||
1554 BID_UNDERFLOW_EXCEPTION & flags)
1564DecimalImpUtil_IntelDfp::ValueType64
1565DecimalImpUtil_IntelDfp::parse64(
const char *
string)
1567 DecimalImpUtil_IntelDfp::ValueType64 result;
1568 _IDEC_flags flags(0);
1571 result.d_raw = __bid64_from_string(
const_cast<char *
>(
string), &flags);
1573 if (BID_OVERFLOW_EXCEPTION & flags ||
1574 BID_UNDERFLOW_EXCEPTION & flags)
1583DecimalImpUtil_IntelDfp::ValueType128
1584DecimalImpUtil_IntelDfp::parse128(
const char *
string)
1586 DecimalImpUtil_IntelDfp::ValueType128 result;
1587 _IDEC_flags flags(0);
1590 result.d_raw = __bid128_from_string(
const_cast<char *
>(
string), &flags);
1592 if (BID_OVERFLOW_EXCEPTION & flags ||
1593 BID_UNDERFLOW_EXCEPTION & flags)
1603DecimalImpUtil_IntelDfp::ValueType32
1604DecimalImpUtil_IntelDfp::parse32(
const char *
string,
unsigned int *status)
1608 DecimalImpUtil_IntelDfp::ValueType32 result;
1616 result.d_raw = __bid32_from_string(
const_cast<char *
>(
string), status);
1623DecimalImpUtil_IntelDfp::ValueType64
1624DecimalImpUtil_IntelDfp::parse64(
const char *
string,
unsigned int *status)
1628 DecimalImpUtil_IntelDfp::ValueType64 result;
1637 result.d_raw = __bid64_from_string(
const_cast<char *
>(
string), status);
1643DecimalImpUtil_IntelDfp::ValueType128
1644DecimalImpUtil_IntelDfp::parse128(
const char *
string,
unsigned int *status)
1648 DecimalImpUtil_IntelDfp::ValueType128 result;
1656 result.d_raw = __bid128_from_string(
const_cast<char *
>(
string), status);
1663DecimalImpUtil_IntelDfp::ValueType32
1667 bsl::memcpy(&value, &dpd,
sizeof(value));
1670 result.d_raw = __bid_dpd_to_bid32(value.d_raw);
1676DecimalImpUtil_IntelDfp::ValueType64
1680 bsl::memcpy(&value, &dpd,
sizeof(value));
1683 result.d_raw = __bid_dpd_to_bid64(value.d_raw);
1689DecimalImpUtil_IntelDfp::ValueType128
1693 bsl::memcpy(&value, &dpd,
sizeof(value));
1695 ValueType128 result;
1696 result.d_raw = __bid_dpd_to_bid128(value.d_raw);
1703DecimalImpUtil_IntelDfp::convertBIDtoDPD(
1704 DecimalImpUtil_IntelDfp::ValueType32 value)
1707 result.d_raw = __bid_to_dpd32(value.d_raw);
1710 bsl::memcpy(&dpd, &result,
sizeof(dpd));
1717DecimalImpUtil_IntelDfp::convertBIDtoDPD(
1718 DecimalImpUtil_IntelDfp::ValueType64 value)
1721 result.d_raw = __bid_to_dpd64(value.d_raw);
1724 bsl::memcpy(&dpd, &result,
sizeof(dpd));
1731DecimalImpUtil_IntelDfp::convertBIDtoDPD(
1732 DecimalImpUtil_IntelDfp::ValueType128 value)
1734 ValueType128 result;
1735 result.d_raw = __bid_to_dpd128(value.d_raw);
1738 bsl::memcpy(&dpd, &result,
sizeof(dpd));
1745DecimalImpUtil_IntelDfp::ValueType32
1749 bsl::memcpy(&result, &bid,
sizeof(result));
1755DecimalImpUtil_IntelDfp::ValueType64
1759 bsl::memcpy(&result, &bid,
sizeof(result));
1765DecimalImpUtil_IntelDfp::ValueType128
1768 ValueType128 result;
1769 bsl::memcpy(&result, &bid,
sizeof(result));
1776DecimalImpUtil_IntelDfp::convertToBID(
1777 DecimalImpUtil_IntelDfp::ValueType32 value)
1780 bsl::memcpy(&bid, &value,
sizeof(bid));
1787DecimalImpUtil_IntelDfp::convertToBID(
1788 DecimalImpUtil_IntelDfp::ValueType64 value)
1791 bsl::memcpy(&bid, &value,
sizeof(bid));
1798DecimalImpUtil_IntelDfp::convertToBID(
1799 DecimalImpUtil_IntelDfp::ValueType128 value)
1802 bsl::memcpy(&bid, &value,
sizeof(bid));
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:231
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1976
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition bdldfp_decimal.h:747
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
ALLOCATOR & lhs
Definition bslstl_string.h:3917
BID_UINT128 Type128
Definition bdldfp_decimalstorage.h:86
BID_UINT64 Type64
Definition bdldfp_decimalstorage.h:85
BID_UINT32 Type32
Definition bdldfp_decimalstorage.h:84
Definition bslmf_issame.h:146