8#ifndef INCLUDED_BDLDFP_DECIMALCONVERTUTIL_INTELDFP
9#define INCLUDED_BDLDFP_DECIMALCONVERTUTIL_INTELDFP
69#include <bdlscm_version.h>
73#ifdef BDLDFP_DECIMALPLATFORM_INTELDFP
81#include <bsl_cstring.h>
92struct DecimalConvertUtil_IntelDfp {
100 static double decimal32ToDouble (Decimal32 decimal);
101 static double decimal64ToDouble (Decimal64 decimal);
102 static double decimal128ToDouble(Decimal128 decimal);
108 static double decimalToDouble (Decimal32 decimal);
109 static double decimalToDouble (Decimal64 decimal);
135 static double decimalToDouble (Decimal128 decimal);
139 static float decimal32ToFloat (Decimal32 decimal);
140 static float decimal64ToFloat (Decimal64 decimal);
141 static float decimal128ToFloat(Decimal128 decimal);
147 static float decimalToFloat (Decimal32 decimal);
148 static float decimalToFloat (Decimal64 decimal);
174 static float decimalToFloat (Decimal128 decimal);
179 static void decimal32ToDPD(
unsigned char *buffer,
181 static void decimal64ToDPD(
unsigned char *buffer,
183 static void decimal128ToDPD(
unsigned char *buffer,
186 static void decimalToDPD(
unsigned char *buffer,
188 static void decimalToDPD(
unsigned char *buffer,
197 static void decimalToDPD(
unsigned char *buffer,
202 static Decimal32 decimal32FromDPD(
const unsigned char *buffer);
203 static Decimal64 decimal64FromDPD(
const unsigned char *buffer);
210 static Decimal128 decimal128FromDPD(
const unsigned char *buffer);
212 static void decimalFromDPD(Decimal32 *decimal,
213 const unsigned char *buffer);
214 static void decimalFromDPD(Decimal64 *decimal,
215 const unsigned char *buffer);
222 static void decimalFromDPD(Decimal128 *decimal,
223 const unsigned char *buffer);
227 static void decimal32ToBID(
unsigned char *buffer,
229 static void decimal64ToBID(
unsigned char *buffer,
231 static void decimal128ToBID(
unsigned char *buffer,
234 static void decimalToBID(
unsigned char *buffer,
236 static void decimalToBID(
unsigned char *buffer,
245 static void decimalToBID(
unsigned char *buffer,
250 static Decimal32 decimal32FromBID(
const unsigned char *buffer);
251 static Decimal64 decimal64FromBID(
const unsigned char *buffer);
258 static Decimal128 decimal128FromBID(
const unsigned char *buffer);
260 static void decimalFromBID(Decimal32 *decimal,
261 const unsigned char *buffer);
262 static void decimalFromBID(Decimal64 *decimal,
263 const unsigned char *buffer);
270 static void decimalFromBID(Decimal128 *decimal,
271 const unsigned char *buffer);
282DecimalConvertUtil_IntelDfp::decimal32ToDouble(
Decimal32 decimal)
284 return decimalToDouble(decimal);
289DecimalConvertUtil_IntelDfp::decimal64ToDouble(
Decimal64 decimal)
291 return decimalToDouble(decimal);
296DecimalConvertUtil_IntelDfp::decimal128ToDouble(
Decimal128 decimal)
298 return decimalToDouble(decimal);
303DecimalConvertUtil_IntelDfp::decimalToDouble(
Decimal32 decimal)
306 return __bid32_to_binary64(decimal.data()->d_raw, &flags);
311DecimalConvertUtil_IntelDfp::decimalToDouble(
Decimal64 decimal)
314 return __bid64_to_binary64(decimal.data()->d_raw, &flags);
319DecimalConvertUtil_IntelDfp::decimalToDouble(
Decimal128 decimal)
322 return __bid128_to_binary64(decimal.data()->d_raw, &flags);
329DecimalConvertUtil_IntelDfp::decimal32ToFloat(
Decimal32 decimal)
331 return decimalToFloat(decimal);
335DecimalConvertUtil_IntelDfp::decimal64ToFloat(
Decimal64 decimal)
337 return decimalToFloat(decimal);
341DecimalConvertUtil_IntelDfp::decimal128ToFloat(
Decimal128 decimal)
343 return decimalToFloat(decimal);
348DecimalConvertUtil_IntelDfp::decimalToFloat(
Decimal32 decimal)
351 return __bid32_to_binary32(decimal.data()->d_raw, &flags);
356DecimalConvertUtil_IntelDfp::decimalToFloat(
Decimal64 decimal)
359 return __bid64_to_binary32(decimal.data()->d_raw, &flags);
364DecimalConvertUtil_IntelDfp::decimalToFloat(
Decimal128 decimal)
367 return __bid128_to_binary32(decimal.data()->d_raw, &flags);
373void DecimalConvertUtil_IntelDfp::decimal32ToDPD(
unsigned char *buffer,
376 decimalToDPD(buffer, decimal);
380void DecimalConvertUtil_IntelDfp::decimal64ToDPD(
unsigned char *buffer,
383 decimalToDPD(buffer, decimal);
387void DecimalConvertUtil_IntelDfp::decimal128ToDPD(
unsigned char *buffer,
390 decimalToDPD(buffer, decimal);
394void DecimalConvertUtil_IntelDfp::decimalToDPD(
unsigned char *buffer,
397 decimal.data()->d_raw = __bid_to_dpd32(decimal.data()->d_raw);
398 bsl::memcpy(buffer, &decimal,
sizeof(decimal));
402void DecimalConvertUtil_IntelDfp::decimalToDPD(
unsigned char *buffer,
405 decimal.data()->d_raw = __bid_to_dpd64(decimal.data()->d_raw);
406 bsl::memcpy(buffer, &decimal,
sizeof(decimal));
410void DecimalConvertUtil_IntelDfp::decimalToDPD(
unsigned char *buffer,
413 decimal.data()->d_raw = __bid_to_dpd128(decimal.data()->d_raw);
414 bsl::memcpy(buffer, &decimal,
sizeof(decimal));
420Decimal32 DecimalConvertUtil_IntelDfp::decimal32FromDPD(
421 const unsigned char *buffer)
426 bsl::memcpy(&value, buffer,
sizeof(value));
427 value.d_raw = __bid_dpd_to_bid32(value.d_raw);
433Decimal64 DecimalConvertUtil_IntelDfp::decimal64FromDPD(
434 const unsigned char *buffer)
439 bsl::memcpy(&value, buffer,
sizeof(value));
440 value.d_raw = __bid_dpd_to_bid64(value.d_raw);
446Decimal128 DecimalConvertUtil_IntelDfp::decimal128FromDPD(
447 const unsigned char *buffer)
452 bsl::memcpy(&value, buffer,
sizeof(value));
453 value.d_raw = __bid_dpd_to_bid128(value.d_raw);
459void DecimalConvertUtil_IntelDfp::decimalFromDPD(
Decimal32 *decimal,
460 const unsigned char *buffer)
465 *decimal = decimal32FromDPD(buffer);
469void DecimalConvertUtil_IntelDfp::decimalFromDPD(
Decimal64 *decimal,
470 const unsigned char *buffer)
475 *decimal = decimal64FromDPD(buffer);
479void DecimalConvertUtil_IntelDfp::decimalFromDPD(
Decimal128 *decimal,
480 const unsigned char *buffer)
485 *decimal = decimal128FromDPD(buffer);
492DecimalConvertUtil_IntelDfp::decimal32ToBID(
unsigned char *buffer,
495 decimalToBID(buffer, decimal);
500DecimalConvertUtil_IntelDfp::decimal64ToBID(
unsigned char *buffer,
503 decimalToBID(buffer, decimal);
507void DecimalConvertUtil_IntelDfp::decimal128ToBID(
unsigned char *buffer,
510 decimalToBID(buffer, decimal);
514void DecimalConvertUtil_IntelDfp::decimalToBID(
unsigned char *buffer,
517 bsl::memcpy(buffer, &decimal,
sizeof(decimal));
521void DecimalConvertUtil_IntelDfp::decimalToBID(
unsigned char *buffer,
524 bsl::memcpy(buffer, &decimal,
sizeof(decimal));
528void DecimalConvertUtil_IntelDfp::decimalToBID(
unsigned char *buffer,
531 bsl::memcpy(buffer, &decimal,
sizeof(decimal));
537Decimal32 DecimalConvertUtil_IntelDfp::decimal32FromBID(
538 const unsigned char *buffer)
543 bsl::memcpy(&value, buffer,
sizeof(value));
549Decimal64 DecimalConvertUtil_IntelDfp::decimal64FromBID(
550 const unsigned char *buffer)
555 bsl::memcpy(&value, buffer,
sizeof(value));
561Decimal128 DecimalConvertUtil_IntelDfp::decimal128FromBID(
562 const unsigned char *buffer)
567 bsl::memcpy(&value, buffer,
sizeof(value));
573void DecimalConvertUtil_IntelDfp::decimalFromBID(
Decimal32 *decimal,
574 const unsigned char *buffer)
579 *decimal = decimal32FromBID(buffer);
583void DecimalConvertUtil_IntelDfp::decimalFromBID(
Decimal64 *decimal,
584 const unsigned char *buffer)
589 *decimal = decimal64FromBID(buffer);
593void DecimalConvertUtil_IntelDfp::decimalFromBID(
Decimal128 *decimal,
594 const unsigned char *buffer)
599 *decimal = decimal128FromBID(buffer);
Imp::ValueType64 ValueType64
Definition bdldfp_decimalimputil.h:250
Imp::ValueType128 ValueType128
Definition bdldfp_decimalimputil.h:251
Imp::ValueType32 ValueType32
Definition bdldfp_decimalimputil.h:249
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdldfp_decimal.h:712
Decimal_Type128 Decimal128
Definition bdldfp_decimal.h:719
Decimal_Type32 Decimal32
Definition bdldfp_decimal.h:714
Decimal_Type64 Decimal64
Definition bdldfp_decimal.h:715