BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bdldfp_decimalimputil_inteldfp.h
Go to the documentation of this file.
1/// @file bdldfp_decimalimputil_inteldfp.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bdldfp_decimalimputil_inteldfp.h -*-C++-*-
8#ifndef INCLUDED_BDLDFP_DECIMALIMPUTIL_INTELDFP
9#define INCLUDED_BDLDFP_DECIMALIMPUTIL_INTELDFP
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id$")
13
14/// @defgroup bdldfp_decimalimputil_inteldfp bdldfp_decimalimputil_inteldfp
15/// @brief Provide utility to implement decimal `float`s on the Intel library.
16/// @addtogroup bdl
17/// @{
18/// @addtogroup bdldfp
19/// @{
20/// @addtogroup bdldfp_decimalimputil_inteldfp
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bdldfp_decimalimputil_inteldfp-purpose"> Purpose</a>
25/// * <a href="#bdldfp_decimalimputil_inteldfp-classes"> Classes </a>
26/// * <a href="#bdldfp_decimalimputil_inteldfp-description"> Description </a>
27/// * <a href="#bdldfp_decimalimputil_inteldfp-usage"> Usage </a>
28///
29/// # Purpose {#bdldfp_decimalimputil_inteldfp-purpose}
30/// Provide utility to implement decimal `float`s on the Intel library.
31///
32/// # Classes {#bdldfp_decimalimputil_inteldfp-classes}
33///
34/// - bdldfp::DecimalImpUtil_IntelDfp: Namespace for Intel decimal FP functions
35///
36/// @see bdldfp_decimal, bdldfp_decimalplatform
37///
38/// # Description {#bdldfp_decimalimputil_inteldfp-description}
39/// This component, `bdldfp::DecimalImpUtil_IntelDfp` is for
40/// internal use only by the `bdldfp_decimal*` components. Direct use of any
41/// names declared in this component by any other code invokes undefined
42/// behavior. In other words: this code may change, disappear, break, move
43/// without notice, and no support whatsoever will ever be provided for it.
44/// This component provides implementations of core Decimal Floating Point
45/// functionality using the Intel DFP library.
46///
47/// ## Usage {#bdldfp_decimalimputil_inteldfp-usage}
48///
49///
50/// This section shows the intended use of this component.
51/// @}
52/** @} */
53/** @} */
54
55/** @addtogroup bdl
56 * @{
57 */
58/** @addtogroup bdldfp
59 * @{
60 */
61/** @addtogroup bdldfp_decimalimputil_inteldfp
62 * @{
63 */
64
65#include <bdlscm_version.h>
66
69
70#ifdef BDLDFP_DECIMALPLATFORM_INTELDFP
72
73#include <bslmf_assert.h>
74#include <bslmf_issame.h>
75#include <bsls_assert.h>
76
77#include <bsl_locale.h>
78#include <bsl_cstring.h>
79#include <bsl_c_errno.h>
80
81
82namespace bdldfp {
83
84 // ==============================
85 // class DecimalImplUtil_IntelDfp
86 // ==============================
87
88/// This `struct` provides a namespace for implementation functions that
89/// work in terms of the underlying C-style decimal floating point
90/// implementation, Intel's DFP library.
91///
92/// See @ref bdldfp_decimalimputil_inteldfp
93struct DecimalImpUtil_IntelDfp {
94
95 // TYPES
96 struct ValueType32 { BID_UINT32 d_raw; };
97 struct ValueType64 { BID_UINT64 d_raw; };
98 struct ValueType128 { BID_UINT128 d_raw; };
99
100 enum {
101 // Status flag bitmask for numeric operations.
102
103 k_STATUS_INEXACT = BID_INEXACT_EXCEPTION,
104 k_STATUS_UNDERFLOW = BID_UNDERFLOW_EXCEPTION,
105 k_STATUS_OVERFLOW = BID_OVERFLOW_EXCEPTION
106 };
107
108 private:
109 // CLASS METHODS
110
111 /// Convert bit flags from the specified `flags` into error codes as
112 /// follows and load the result into a prepocessor macro `errno`:
113 ///
114 /// * flag BID_INVALID_EXCEPTION => `errno = EDOM`
115 /// * flag BID_OVERFLOW_EXCEPTION => `errno = ERANGE`
116 /// * flag BID_UNDERFLOW_EXCEPTION => `errno = ERANGE`
117 /// * flag BID_ZERO_DIVIDE_EXCEPTION => `errno = ERANGE`
118 static void setErrno(_IDEC_flags flags);
119
120 public:
121 // CLASS METHODS
122
123 // Integer construction (32-bit)
124
125 static ValueType32 int32ToDecimal32 ( int value);
126 static ValueType32 uint32ToDecimal32 (unsigned int value);
127 static ValueType32 int64ToDecimal32 ( long long int value);
128
129 /// Return a `Decimal32` object having the value closest to the
130 /// specified `value` following the conversion rules as defined by
131 /// IEEE-754:
132 ///
133 /// * If `value` is zero then initialize this object to a zero with an
134 /// unspecified sign and an unspecified exponent.
135 /// * Otherwise if `value` has a value that is not exactly
136 /// representable using `std::numeric_limits<Decimal32>::max_digit`
137 /// decimal digits then return the value rounded according to the
138 /// rounding direction.
139 /// * Otherwise initialize this object to the value of the `value`.
140 ///
141 /// The exponent 0 (quantum 1e-6) is preferred during conversion unless
142 /// it would cause unnecessary loss of precision.
143 static ValueType32 uint64ToDecimal32 (unsigned long long int value);
144
145 // Integer construction (64-bit)
146
147 static ValueType64 int32ToDecimal64 ( int value);
148 static ValueType64 uint32ToDecimal64 (unsigned int value);
149 static ValueType64 int64ToDecimal64 ( long long int value);
150
151 /// Return a `Decimal64` object having the value closest to the
152 /// specified `value` following the conversion rules as defined by
153 /// IEEE-754:
154 ///
155 /// * If `value` is zero then initialize this object to a zero with an
156 /// unspecified sign and an unspecified exponent.
157 /// * Otherwise if `value` has a value that is not exactly
158 /// representable using `std::numeric_limits<Decimal64>::max_digit`
159 /// decimal digits then return `value` rounded according to the
160 /// rounding direction.
161 /// * Otherwise initialize this object to the value of the `value`.
162 ///
163 /// The exponent 0 (quantum 1e-15) is preferred during conversion unless
164 /// it would cause unnecessary loss of precision.
165 static ValueType64 uint64ToDecimal64 (unsigned long long int value);
166
167 // Integer construction (128-bit)
168
169 static ValueType128 int32ToDecimal128( int value);
170 static ValueType128 uint32ToDecimal128(unsigned int value);
171 static ValueType128 int64ToDecimal128( long long int value);
172
173 /// Return a `Decimal128` object having the value closest to the
174 /// specified `value` subject to the conversion rules as defined by
175 /// IEEE-754:
176 ///
177 /// * If `value` is zero then initialize this object to a zero with an
178 /// unspecified sign and an unspecified exponent.
179 /// * Otherwise if `value` has a value that is not exactly
180 /// representable using `std::numeric_limits<Decimal128>::max_digit`
181 /// decimal digits then return `value` rounded according to the
182 /// rounding direction.
183 /// * Otherwise initialize this object to `value`.
184 ///
185 /// The exponent 0 (quantum 1e-33) is preferred during conversion unless
186 /// it would cause unnecessary loss of precision.
187 static ValueType128 uint64ToDecimal128(unsigned long long int value);
188
189 // Arithmetic functions
190
191 // Addition functions
192
193 /// Add the value of the specified `rhs` to the value of the specified
194 /// `lhs` as described by IEEE-754 and return the result.
195 ///
196 /// * If either of `lhs` or `rhs` is signaling NaN, then store the
197 /// value of the macro `EDOM` into `errno` and return a NaN.
198 /// * Otherwise if either of `lhs` or `rhs` is NaN, return a NaN.
199 /// * Otherwise if `lhs` and `rhs` are infinities of differing signs,
200 /// store the value of the macro `EDOM` into `errno` and return a
201 /// NaN.
202 /// * Otherwise if `lhs` and `rhs` are infinities of the same sign then
203 /// return infinity of that sign.
204 /// * Otherwise if `rhs` is zero (positive or negative), return `lhs`.
205 /// * Otherwise if the sum of `lhs` and `rhs` has an absolute value
206 /// that is larger than max value supported by indicated result type
207 /// then store the value of the macro `ERANGE` into `errno` and
208 /// return infinity with the same sign as that result.
209 /// * Otherwise return the sum of the number represented by `lhs` and
210 /// the number represented by `rhs`.
211 static ValueType32 add(ValueType32 lhs, ValueType32 rhs);
212 static ValueType64 add(ValueType64 lhs, ValueType64 rhs);
213 static ValueType128 add(ValueType128 lhs, ValueType128 rhs);
214
215 // Subtraction functions
216
217 /// Subtract the value of the specified `rhs` from the value of the
218 /// specified `lhs` as described by IEEE-754 and return the result.
219 ///
220 /// * If either of `lhs` or `rhs` is signaling NaN, then store the
221 /// value of the macro `EDOM` into `errno` and return a NaN.
222 /// * Otherwise if either of `lhs` or `rhs` is NaN, return a NaN.
223 /// * Otherwise if `lhs` and the `rhs` have infinity values of the same
224 /// sign, store the value of the macro `EDOM` into `errno` and return
225 /// a NaN.
226 /// * Otherwise if `lhs` and the `rhs` have infinity values of
227 /// differing signs, then return `lhs`.
228 /// * Otherwise if `rhs` has a zero value (positive or negative), then
229 /// return `lhs`.
230 /// * Otherwise if the subtracting of `lhs` and `rhs` has an absolute
231 /// value that is larger than max value supported by indicated result
232 /// type then store the value of the macro `ERANGE` into `errno` and
233 /// return infinity with the same sign as that result.
234 /// * Otherwise return the result of subtracting the value of `rhs`
235 /// from the value of `lhs`.
236 static ValueType32 subtract(ValueType32 lhs, ValueType32 rhs);
237 static ValueType64 subtract(ValueType64 lhs, ValueType64 rhs);
238 static ValueType128 subtract(ValueType128 lhs, ValueType128 rhs);
239
240 // Multiplication functions
241
242 /// Multiply the value of the specified `lhs` object by the value of the
243 /// specified `rhs` as described by IEEE-754 and return the result.
244 ///
245 /// * If either of `lhs` or `rhs` is signaling NaN, then store the
246 /// value of the macro `EDOM` into `errno` and return a NaN.
247 /// * Otherwise if either of `lhs` or `rhs` is NaN, return a NaN.
248 /// * Otherwise if one of the operands is infinity (positive or
249 /// negative) and the other is zero (positive or negative), then
250 /// store the value of the macro `EDOM` into `errno` and return a
251 /// NaN.
252 /// * Otherwise if both `lhs` and `rhs` are infinity (positive or
253 /// negative), return infinity. The sign of the returned value will
254 /// be positive if `lhs` and `rhs` have the same sign, and negative
255 /// otherwise.
256 /// * Otherwise, if either `lhs` or `rhs` is zero, return zero. The
257 /// sign of the returned value will be positive if `lhs` and `rhs`
258 /// have the same sign, and negative otherwise.
259 /// * Otherwise if the product of `lhs` and `rhs` has an absolute value
260 /// that is larger than max value of the indicated result type then
261 /// store the value of the macro `ERANGE` into `errno` and return
262 /// infinity with the same sign as that result.
263 /// * Otherwise if the product of `lhs` and `rhs` has an absolute value
264 /// that is smaller than min value of the indicated result type then
265 /// store the value of the macro `ERANGE` into `errno` and return
266 /// zero with the same sign as that result.
267 /// * Otherwise return the product of the value of `rhs` and the number
268 /// represented by `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);
272
273 // Division functions
274
275 /// Divide the value of the specified `lhs` by the value of the
276 /// specified `rhs` as described by IEEE-754, and return the result.
277 ///
278 /// * If either of `lhs` or `rhs` is signaling NaN, then store the
279 /// value of the macro `EDOM` into `errno` and return a NaN.
280 /// * Otherwise if either of `lhs` or `rhs` is NaN, return a NaN.
281 /// * Otherwise if `lhs` and `rhs` are both infinity (positive or
282 /// negative) or both zero (positive or negative) then store the
283 /// value of the macro `EDOM` into `errno` and return a NaN.
284 /// * Otherwise if `lhs` has a normal value and `rhs` has a positive
285 /// zero value, store the value of the macro `ERANGE` into `errno`
286 /// and return infinity with the sign of `lhs`.
287 /// * Otherwise if `lhs` has a normal value and `rhs` has a negative
288 /// zero value, store the value of the macro `ERANGE` into `errno`
289 /// and return infinity with the opposite sign as `lhs`.
290 /// * Otherwise if `lhs` has infinity value and `rhs` has a positive
291 /// zero value, return infinity with the sign of `lhs`.
292 /// * Otherwise if `lhs` has infinity value and `rhs` has a negative
293 /// zero value, return infinity with the opposite sign as `lhs`.
294 /// * Otherwise if dividing the value of `lhs` with the value of `rhs`
295 /// results in an absolute value that is larger than max value
296 /// supported by the return type then store the value of the macro
297 /// `ERANGE` into `errno` and return infinity with the same sign as
298 /// that result.
299 /// * Otherwise if dividing the value of `lhs` with the value of `rhs`
300 /// results in an absolute value that is smaller than min value
301 /// supported by indicated result type then store the value of the
302 /// macro `ERANGE` into `errno`and return zero with the same sign as
303 /// that result.
304 /// * Otherwise return the result of dividing the value of `lhs` with
305 /// the value of `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);
309
310 // Negation functions
311
312 /// Return the result of applying the unary - operator to the specified `value` as described by IEEE-754.
313 ///
314 /// \note Note that floating-point numbers
315 /// have signed zero, therefore this operation is not the same as
316 /// `0-value`.
317 static ValueType32 negate(ValueType32 value);
318 static ValueType64 negate(ValueType64 value);
319 static ValueType128 negate(ValueType128 value);
320
321 // Comparison functions
322
323 // Less Than functions
324
325 /// Return `true` if the specified `lhs` has a value less than the
326 /// specified `rhs` and `false` otherwise. The value of a `Decimal64`
327 /// object `lhs` is less than that of an object `rhs` if the
328 /// `compareQuietLess` operation (IEEE-754 defined, non-total ordering
329 /// comparison) considers the underlying IEEE representation of `lhs` to
330 /// be less than of that of `rhs`. In other words, `lhs` is less than
331 /// `rhs` if:
332 ///
333 /// * neither `lhs` nor `rhs` are NaN, or
334 /// * `lhs` is zero (positive or negative) and `rhs` is positive, or
335 /// * `rhs` is zero (positive or negative) and `lhs` negative, or
336 /// * `lhs` is not positive infinity, or
337 /// * `lhs` is negative infinity and `rhs` is not, or
338 /// * `lhs` and `rhs` both represent a real number and the real number
339 /// of `lhs` is less than that of `rhs`
340 ///
341 /// If either or both operands are signaling NaN, store the value of the
342 /// macro `EDOM` into `errno` and return `false`.
343 static bool less(ValueType32 lhs, ValueType32 rhs);
344 static bool less(ValueType64 lhs, ValueType64 rhs);
345 static bool less(ValueType128 lhs, ValueType128 rhs);
346
347 // Greater Than functions
348
349 /// Return `true` if the specified `lhs` has a greater value than the
350 /// specified `rhs` and `false` otherwise. The value of a `Decimal64`
351 /// object `lhs` is greater than that of an object `rhs` if the
352 /// `compareQuietGreater` operation (IEEE-754 defined, non-total
353 /// ordering comparison) considers the underlying IEEE representation of
354 /// `lhs` to be greater than of that of `rhs`. In other words, `lhs` is
355 /// greater than `rhs` if:
356 ///
357 /// * neither `lhs` nor `rhs` are NaN, or
358 /// * `rhs` is zero (positive or negative) and `lhs` positive, or
359 /// * `lhs` is zero (positive or negative) and `rhs` negative, or
360 /// * `lhs` is not negative infinity, or
361 /// * `lhs` is positive infinity and `rhs` is not, or
362 /// * `lhs` and `rhs` both represent a real number and the real number
363 /// of `lhs` is greater than that of `rhs`
364 ///
365 /// If either or both operands are signaling NaN, store the value of the
366 /// macro `EDOM` into `errno` and return `false`.
367 static bool greater(ValueType32 lhs, ValueType32 rhs);
368 static bool greater(ValueType64 lhs, ValueType64 rhs);
369 static bool greater(ValueType128 lhs, ValueType128 rhs);
370
371 // Less Or Equal functions
372
373 /// Return `true` if the specified `lhs` has a value less than or equal
374 /// the value of the specified `rhs` and `false` otherwise. The value
375 /// of a `Decimal64` object `lhs` is less than or equal to the value of
376 /// an object `rhs` if the `compareQuietLessEqual` operation (IEEE-754
377 /// defined, non-total ordering comparison) considers the underlying
378 /// IEEE representation of `lhs` to be less or equal to that of `rhs`.
379 /// In other words, `lhs` is less or equal than `rhs` if:
380 ///
381 /// * neither `lhs` nor `rhs` are NaN, or
382 /// * `lhs` and `rhs` are both zero (positive or negative), or
383 /// * both `lhs` and `rhs` are positive infinity, or
384 /// * `lhs` is negative infinity, or
385 /// * `lhs` and `rhs` both represent a real number and the real number
386 /// of `lhs` is less or equal to that of `rhs`
387 ///
388 /// If either or both operands are signaling NaN, store the value of the
389 /// macro `EDOM` into `errno` and return `false`.
390 static bool lessEqual(ValueType32 lhs, ValueType32 rhs);
391 static bool lessEqual(ValueType64 lhs, ValueType64 rhs);
392 static bool lessEqual(ValueType128 lhs, ValueType128 rhs);
393
394 // Greater Or Equal functions
395
396 /// Return `true` if the specified `lhs` has a value greater than or
397 /// equal to the value of the specified `rhs` and `false` otherwise.
398 /// The value of a `Decimal64` object `lhs` is greater or equal to a
399 /// `Decimal64` object `rhs` if the `compareQuietGreaterEqual` operation
400 /// (IEEE-754 defined, non-total ordering comparison ) considers the
401 /// underlying IEEE representation of `lhs` to be greater or equal to
402 /// that of `rhs`. In other words, `lhs` is greater than or equal to
403 /// `rhs` if:
404 ///
405 /// * neither `lhs` nor `rhs` are NaN, or
406 /// * `lhs` and `rhs` are both zero (positive or negative), or
407 /// * both `lhs` and `rhs` are negative infinity, or
408 /// * `lhs` is positive infinity, or
409 /// * `lhs` and `rhs` both represent a real number and the real number
410 /// of `lhs` is greater or equal to that of `rhs`
411 ///
412 /// If either or both operands are signaling NaN, store the value of the
413 /// macro `EDOM` into `errno` and return `false`.
414 static bool greaterEqual(ValueType32 lhs, ValueType32 rhs);
415 static bool greaterEqual(ValueType64 lhs, ValueType64 rhs);
416 static bool greaterEqual(ValueType128 lhs, ValueType128 rhs);
417
418 // Equality functions
419
420 /// Return `true` if the specified `lhs` and `rhs` have the same value,
421 /// and `false` otherwise. Two decimal objects have the same value if
422 /// the `compareQuietEqual` operation (IEEE-754 defined, non-total
423 /// ordering comparison) considers the underlying IEEE representations
424 /// equal. In other words, two decimal objects have the same value if:
425 ///
426 /// * both have a zero value (positive or negative), or
427 /// * both have the same infinity value (both positive or negative), or
428 /// * both have the value of a real number that are equal, even if they
429 /// are represented differently (cohorts have the same value)
430 ///
431 /// If either or both operands are signaling NaN, store the value of the
432 /// macro `EDOM` into `errno` and return `false`.
433 static bool equal(ValueType32 lhs, ValueType32 rhs);
434 static bool equal(ValueType64 lhs, ValueType64 rhs);
435 static bool equal(ValueType128 lhs, ValueType128 rhs);
436
437 // Inequality functions
438
439 /// Return `false` if the specified `lhs` and `rhs` have the same value,
440 /// and `true` otherwise. Two decimal objects have the same value if
441 /// the `compareQuietEqual` operation (IEEE-754 defined, non-total
442 /// ordering comparison) considers the underlying IEEE representations
443 /// equal. In other words, two decimal objects have the same value if:
444 ///
445 /// * both have a zero value (positive or negative), or
446 /// * both have the same infinity value (both positive or negative), or
447 /// * both have the value of a real number that are equal, even if they
448 /// are represented differently (cohorts have the same value)
449 ///
450 /// If either or both operands are signaling NaN, store the value of the
451 /// macro `EDOM` into `errno` and return `false`.
452 static bool notEqual(ValueType32 lhs, ValueType32 rhs);
453 static bool notEqual(ValueType64 lhs, ValueType64 rhs);
454 static bool notEqual(ValueType128 lhs, ValueType128 rhs);
455
456 // Inter-type Conversion functions
457
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);
462
463 /// Convert the specified `input` to the closest value of indicated
464 /// result type following the conversion rules:
465 ///
466 /// * If `input` is signaling NaN, store the value of the macro `EDOM`
467 /// into `errno` and return signaling NaN value.
468 /// * If `input` is NaN, return NaN value.
469 /// * Otherwise if `input` is infinity (positive or negative), then
470 /// return infinity with the same sign.
471 /// * Otherwise if `input` is zero (positive or negative), then
472 /// return zero with the same sign.
473 /// * Otherwise if `input` has an absolute value that is larger than
474 /// maximum or is smaller than minimum value supported by the result
475 /// type, store the value of the macro `ERANGE` into `errno` and
476 /// return infinity or zero with the same sign respectively.
477 /// * Otherwise if `input` has a value that is not exactly
478 /// representable using maximum digit number supported by indicated
479 /// result type then return the `input` rounded according to the
480 /// rounding direction.
481 /// * Otherwise return `input` value of the result type.
482 static ValueType128 convertToDecimal128(const ValueType32& input);
483 static ValueType128 convertToDecimal128(const ValueType64& input);
484
485 // Binary floating point conversion functions
486
487 /// Create a `Decimal32` object having the value closest to the
488 /// specified `value` following the conversion rules as defined by
489 /// IEEE-754:
490 ///
491 /// * If `value` is signaling NaN, store the value of the macro `EDOM`
492 /// into `errno` and return signaling NaN value.
493 /// * If `value` is NaN, return a NaN.
494 /// * Otherwise if `value` is infinity (positive or negative), then
495 /// return an object equal to infinity with the same sign.
496 /// * Otherwise if `value` is a zero value, then return an object equal
497 /// to zero with the same sign.
498 /// * Otherwise if `value` has an absolute value that is larger than
499 /// `std::numeric_limits<Decimal32>::max()` then store the value of
500 /// the macro `ERANGE` into `errno` and return infinity with the same
501 /// sign as `value`.
502 /// * Otherwise if `value` has an absolute value that is smaller than
503 /// `std::numeric_limits<Decimal32>::min()` then store the value of
504 /// the macro `ERANGE` into `errno` and return a zero with the same
505 /// sign as `value`.
506 /// * Otherwise if `value` needs more than
507 /// `std::numeric_limits<Decimal32>::max_digit` significant decimal
508 /// digits to represent then return the `value` rounded according to
509 /// the rounding direction.
510 /// * Otherwise return a `Decimal32` object representing `value`.
511 static ValueType32 binaryToDecimal32( float value);
512 static ValueType32 binaryToDecimal32( double value);
513
514 /// Create a `Decimal64` object having the value closest to the
515 /// specified `value` following the conversion rules as defined by
516 /// IEEE-754:
517 ///
518 /// * If `value` is NaN, return a NaN.
519 /// * Otherwise if `value` is infinity (positive or negative), then
520 /// return an object equal to infinity with the same sign.
521 /// * Otherwise if `value` is a zero value, then return an object equal
522 /// to zero with the same sign.
523 /// * Otherwise if `value` needs more than
524 /// `std::numeric_limits<Decimal64>::max_digit` significant decimal
525 /// digits to represent then return the `value` rounded according to
526 /// the rounding direction.
527 /// * Otherwise return a `Decimal64` object representing `value`.
528 static ValueType64 binaryToDecimal64( float value);
529 static ValueType64 binaryToDecimal64( double value);
530
531 /// Create a `Decimal128` object having the value closest to the
532 /// specified `value` following the conversion rules as defined by
533 /// IEEE-754:
534 ///
535 /// * If `value` is NaN, return a NaN.
536 /// * Otherwise if `value` is infinity (positive or negative), then
537 /// return an object equal to infinity with the same sign.
538 /// * Otherwise if `value` is a zero value, then return an object equal
539 /// to zero with the same sign.
540 /// * Otherwise if `value` needs more than
541 /// `std::numeric_limits<Decimal128>::max_digit` significant decimal
542 /// digits to represent then return the `value` rounded according to
543 /// the rounding direction.
544 /// * Otherwise return a `Decimal128` object representing `value`.
545 static ValueType128 binaryToDecimal128( float value);
546 static ValueType128 binaryToDecimal128( double value);
547
548 // makeDecimalRaw functions
549
550 /// Create a `ValueType32` object representing a decimal floating point
551 /// number consisting of the specified `significand` and `exponent`,
552 /// with the sign given by `significand`.
553 ///
554 /// \pre The behavior is undefined unless `abs(significand) <= 9,999,999` and `-101 <= exponent <= 90`.
555 static ValueType32 makeDecimalRaw32(int significand, int exponent);
556
557 /// Create a `ValueType64` object representing a decimal floating point
558 /// number consisting of the specified `significand` and `exponent`,
559 /// with the sign given by `significand`.
560 ///
561 /// \pre The behavior is undefined unless `abs(significand) <= 9,999,999,999,999,999` and
562 /// `-398 <= exponent <= 369`.
563 static ValueType64 makeDecimalRaw64(unsigned long long int significand,
564 int exponent);
565 static ValueType64 makeDecimalRaw64( long long int significand,
566 int exponent);
567 static ValueType64 makeDecimalRaw64(unsigned int significand,
568 int exponent);
569 static ValueType64 makeDecimalRaw64( int significand,
570 int exponent);
571
572 /// Create a `ValueType128` object representing a decimal floating point
573 /// number consisting of the specified `significand` and `exponent`,
574 /// with the sign given by `significand`.
575 ///
576 /// \pre The behavior is undefined unless `-6176 <= exponent <= 6111`.
577 static ValueType128 makeDecimalRaw128(unsigned long long int significand,
578 int exponent);
579 static ValueType128 makeDecimalRaw128( long long int significand,
580 int exponent);
581 static ValueType128 makeDecimalRaw128(unsigned int significand,
582 int exponent);
583 static ValueType128 makeDecimalRaw128( int significand,
584 int exponent);
585
586 // IEEE Scale B functions
587
588 /// Return the result of multiplying the specified `value` by ten raised
589 /// to the specified `exponent`. The quantum of `value` is scaled
590 /// according to IEEE 754's `scaleB` operations. The result is
591 /// unspecified if `value` is NaN or infinity.
592 static ValueType32 scaleB(ValueType32 value, int exponent);
593 static ValueType64 scaleB(ValueType64 value, int exponent);
594 static ValueType128 scaleB(ValueType128 value, int exponent);
595
596 // Parsing functions
597
598 /// Parse the specified `string` as a 32 bit decimal floating-point
599 /// value and return the result. The parsing is as specified for the
600 /// `strtod32` function in section 9.6 of the ISO/EIC TR 24732 C Decimal
601 /// Floating-Point Technical Report, except that it is unspecified
602 /// whether the NaNs returned are quiet or signaling. If `string`
603 /// represents a value that absolute value exceeds the maximum value or
604 /// is less than the smallest value supported by `ValueType32` type then
605 /// store the value of the macro `ERANGE` into `errno` and return the
606 /// value initialized to infinity or zero respectively with the same sign as specified in `string`.
607 ///
608 /// \pre The behavior is undefined unless
609 /// `input` represents a valid 32 bit decimalfloating-point number in
610 /// scientific or fixed notation, and no unrelated characters precede
611 /// (not even whitespace) that textual representation and a terminating nul character immediately follows it.
612 ///
613 /// \note Note that this method does
614 /// not guarantee the behavior of ISO/EIC TR 24732 C when parsing NaN
615 /// because the AIX compiler intrinsics return a signaling NaN.
616 static ValueType32 parse32 (const char *string);
617
618 /// Parse the specified `string` string as a 64 bit decimal floating-
619 /// point value and return the result. The parsing is as specified for
620 /// the `strtod64` function in section 9.6 of the ISO/EIC TR 24732 C
621 /// Decimal Floating-Point Technical Report, except that it is
622 /// unspecified whether the NaNs returned are quiet or signaling. If
623 /// `string` represents a value that absolute value exceeds the maximum
624 /// value or is less than the smallest value supported by `ValueType63`
625 /// type then store the value of the macro `ERANGE` into `errno` and
626 /// return the value initialized to infinity or zero respectively with
627 /// the same sign as specified in `string`.
628 ///
629 /// \pre The behavior is undefined unless `input` represents a valid 64 bit decimal floating-point
630 /// number in scientific or fixed notation, and no unrelated characters
631 /// precede (not even whitespace) that textual representation and a terminating nul character immediately follows it.
632 ///
633 /// \note Note that this
634 /// method does not guarantee the behavior of ISO/EIC TR 24732 C when
635 /// parsing NaN because the AIX compiler intrinsics return a signaling
636 /// NaN.
637 static ValueType64 parse64(const char *string);
638
639 /// Parse the specified `string` string as a 128 bit decimal floating-
640 /// point value and return the result. The parsing is as specified for
641 /// the `strtod128` function in section 9.6 of the ISO/EIC TR 24732 C
642 /// Decimal Floating-Point Technical Report, except that it is
643 /// unspecified whether the NaNs returned are quiet or signaling. If
644 /// `string` represents a value that absolute value exceeds the maximum
645 /// value or is less than the smallest value supported by `ValueType128`
646 /// type then store the value of the macro `ERANGE` into `errno` and
647 /// return the value initialized to infinity or zero respectively with
648 /// the same sign as specified in `string`.
649 ///
650 /// \pre The behavior is undefined unless `input` represents a valid 128 bit decimal floating-point
651 /// number in scientific or fixed notation, and no unrelated characters
652 /// precede (not even whitespace) that textual representation and a terminating null character immediately follows it.
653 ///
654 /// \note Note that this
655 /// method does not guarantee the behavior of ISO/EIC TR 24732 C when
656 /// parsing NaN because the AIX compiler intrinsics return a signaling
657 /// NaN.
658 static ValueType128 parse128(const char *string);
659
660 static ValueType32 parse32(const char *string, unsigned int *status);
661 static ValueType64 parse64(const char *string, unsigned int *status);
662
663 /// Parse the specified `string` string as a decimal floating-point
664 /// value and return the result, loading the specified `status` with a
665 /// bit mask providing additional status information about the result.
666 /// The supplied `*status` must be 0, and may be loaded with a bit mask
667 /// of `k_STATUS_INEXACT`, `k_STATUS_UNDERFLOW`, and `k_STATUS_OVERFLOW`
668 /// constants indicating wether the conversion from text inexact,
669 /// underflowed, or overflowed (or some combination) respectively. The
670 /// parsing is as specified for the `strtod128` function in section 9.6
671 /// of the ISO/EIC TR 24732 C Decimal Floating-Point Technical Report,
672 /// except that it is unspecified whether the NaNs returned are quiet or signaling.
673 ///
674 /// \pre The behavior is undefined unless `input` represents a
675 /// valid decimal floating-point number in scientific or fixed notation,
676 /// and no unrelated characters precede (not even whitespace) that
677 /// textual representation and a terminating null character immediately follows it.
678 ///
679 /// \pre The behavior is undefined unless `*status` is 0.
680 ///
681 /// \note Note that this method does not guarantee the behavior of ISO/EIC TR 24732
682 /// C when parsing NaN because the AIX compiler intrinsics return a
683 /// signaling NaN. Also note that the intel decimal floating point
684 /// library documents that inexact, underflow, and overflow are the
685 /// possible floating point exceptions for this operation.
686 static ValueType128 parse128(const char *string, unsigned int *status);
687
688 // Densely Packed Conversion Functions
689
690 /// Return a `ValueTypeXX` representing the specified `dpd`, which is
691 /// currently in Densely Packed Decimal (DPD) format. This format is
692 /// compatible with the IBM compiler's native type.
693 static ValueType32 convertDPDtoBID(DecimalStorage::Type32 dpd);
694 static ValueType64 convertDPDtoBID(DecimalStorage::Type64 dpd);
695 static ValueType128 convertDPDtoBID(DecimalStorage::Type128 dpd);
696
697 /// Return a `DenselyPackedDecimalImpUtil::StorageTypeXX` representing
698 /// the specified `value` in Densely Packed Decimal (DPD) format. This
699 /// format is compatible with the IBM compiler's native type.
700 static DecimalStorage::Type32 convertBIDtoDPD(ValueType32 value);
701 static DecimalStorage::Type64 convertBIDtoDPD(ValueType64 value);
702 static DecimalStorage::Type128 convertBIDtoDPD(ValueType128 value);
703
704 // Binary Integral Conversion Functions
705
706 /// Return a `ValueTypeXX` representing the specified `bid`, which is
707 /// currently in Binary Integral Decimal (BID) format. This format is
708 /// compatible with the Intel DFP implementation type.
709 static ValueType32 convertFromBID(DecimalStorage::Type32 bid);
710 static ValueType64 convertFromBID(DecimalStorage::Type64 bid);
711 static ValueType128 convertFromBID(DecimalStorage::Type128 bid);
712
713 /// Return a `DecimalStorage::TypeXX` representing
714 /// the specified `value` in Binary Integral Decimal (BID) format. This
715 /// format is compatible with the Intel DFP implementation type.
716 static
717 DecimalStorage::Type32 convertToBID(ValueType32 value);
718 static
719 DecimalStorage::Type64 convertToBID(ValueType64 value);
720 static
721 DecimalStorage::Type128 convertToBID(ValueType128 value);
722};
723
724// ============================================================================
725// INLINE DEFINITIONS
726// ============================================================================
727
728 // -----------------------------
729 // class DecimalImpUtil_IntelDfp
730 // -----------------------------
731
732// CLASS METHODS
733inline
734void DecimalImpUtil_IntelDfp::setErrno(_IDEC_flags flags)
735{
736 if (BID_INVALID_EXCEPTION & flags) {
737 errno = EDOM;
738 }
739 else if (BID_OVERFLOW_EXCEPTION & flags ||
740 BID_UNDERFLOW_EXCEPTION & flags ||
741 BID_ZERO_DIVIDE_EXCEPTION & flags)
742 {
743 errno = ERANGE;
744 }
745}
746
747// CLASS METHODS
748
749 // Integer construction
750
751inline
752DecimalImpUtil_IntelDfp::ValueType32
753DecimalImpUtil_IntelDfp::int32ToDecimal32(int value)
754{
755 DecimalImpUtil_IntelDfp::ValueType32 retval;
756 _IDEC_flags flags(0);
757 retval.d_raw = __bid32_from_int32(value, &flags);
758 return retval;
759}
760
761inline
762DecimalImpUtil_IntelDfp::ValueType64
763DecimalImpUtil_IntelDfp::int32ToDecimal64(int value)
764{
765 DecimalImpUtil_IntelDfp::ValueType64 retval;
766 retval.d_raw = __bid64_from_int32(value);
767 return retval;
768}
769
770inline
771DecimalImpUtil_IntelDfp::ValueType128
772DecimalImpUtil_IntelDfp::int32ToDecimal128(int value)
773{
774 DecimalImpUtil_IntelDfp::ValueType128 retval;
775 retval.d_raw = __bid128_from_int32(value);
776 return retval;
777}
778
779
780inline
781DecimalImpUtil_IntelDfp::ValueType32
782DecimalImpUtil_IntelDfp::uint32ToDecimal32(unsigned int value)
783{
784 DecimalImpUtil_IntelDfp::ValueType32 retval;
785 _IDEC_flags flags(0);
786 retval.d_raw = __bid32_from_uint32(value, &flags);
787 return retval;
788}
789
790inline
791DecimalImpUtil_IntelDfp::ValueType64
792DecimalImpUtil_IntelDfp::uint32ToDecimal64(unsigned int value)
793{
794 DecimalImpUtil_IntelDfp::ValueType64 retval;
795 retval.d_raw = __bid64_from_uint32(value);
796 return retval;
797}
798
799inline
800DecimalImpUtil_IntelDfp::ValueType128
801DecimalImpUtil_IntelDfp::uint32ToDecimal128(unsigned int value)
802{
803 DecimalImpUtil_IntelDfp::ValueType128 retval;
804 retval.d_raw = __bid128_from_uint32(value);
805 return retval;
806}
807
808
809inline
810DecimalImpUtil_IntelDfp::ValueType32
811DecimalImpUtil_IntelDfp::int64ToDecimal32(long long int value)
812{
813 DecimalImpUtil_IntelDfp::ValueType32 retval;
814 _IDEC_flags flags(0);
815 retval.d_raw = __bid32_from_int64(value, &flags);
816 return retval;
817}
818
819inline
820DecimalImpUtil_IntelDfp::ValueType64
821DecimalImpUtil_IntelDfp::int64ToDecimal64(long long int value)
822{
823 DecimalImpUtil_IntelDfp::ValueType64 retval;
824 _IDEC_flags flags(0);
825 retval.d_raw = __bid64_from_int64(value, &flags);
826 return retval;
827}
828
829inline
830DecimalImpUtil_IntelDfp::ValueType128
831DecimalImpUtil_IntelDfp::int64ToDecimal128(long long int value)
832{
833 DecimalImpUtil_IntelDfp::ValueType128 retval;
834 retval.d_raw = __bid128_from_int64(value);
835 return retval;
836}
837
838
839inline
840DecimalImpUtil_IntelDfp::ValueType32
841DecimalImpUtil_IntelDfp::uint64ToDecimal32(unsigned long long int value)
842{
843 DecimalImpUtil_IntelDfp::ValueType32 retval;
844 _IDEC_flags flags(0);
845 retval.d_raw = __bid32_from_uint64(value, &flags);
846 return retval;
847}
848
849inline
850DecimalImpUtil_IntelDfp::ValueType64
851DecimalImpUtil_IntelDfp::uint64ToDecimal64(unsigned long long int value)
852{
853 DecimalImpUtil_IntelDfp::ValueType64 retval;
854 _IDEC_flags flags(0);
855 retval.d_raw = __bid64_from_uint64(value, &flags);
856 return retval;
857}
858
859inline
860DecimalImpUtil_IntelDfp::ValueType128
861DecimalImpUtil_IntelDfp::uint64ToDecimal128(unsigned long long int value)
862{
863 DecimalImpUtil_IntelDfp::ValueType128 retval;
864 retval.d_raw = __bid128_from_uint64(value);
865 return retval;
866}
867
868 // Arithmetic
869
870 // Addition Functions
871
872inline
873DecimalImpUtil_IntelDfp::ValueType32
874DecimalImpUtil_IntelDfp::add(DecimalImpUtil_IntelDfp::ValueType32 lhs,
875 DecimalImpUtil_IntelDfp::ValueType32 rhs)
876{
877 DecimalImpUtil_IntelDfp::ValueType32 retval;
878 _IDEC_flags flags(0);
879 retval.d_raw = __bid32_add(lhs.d_raw, rhs.d_raw, &flags);
880 setErrno(flags);
881 return retval;
882}
883
884inline
885DecimalImpUtil_IntelDfp::ValueType64
886DecimalImpUtil_IntelDfp::add(DecimalImpUtil_IntelDfp::ValueType64 lhs,
887 DecimalImpUtil_IntelDfp::ValueType64 rhs)
888{
889 DecimalImpUtil_IntelDfp::ValueType64 retval;
890 _IDEC_flags flags(0);
891 retval.d_raw = __bid64_add(lhs.d_raw, rhs.d_raw, &flags);
892 setErrno(flags);
893 return retval;
894}
895
896inline
897DecimalImpUtil_IntelDfp::ValueType128
898DecimalImpUtil_IntelDfp::add(DecimalImpUtil_IntelDfp::ValueType128 lhs,
899 DecimalImpUtil_IntelDfp::ValueType128 rhs)
900{
901 DecimalImpUtil_IntelDfp::ValueType128 retval;
902 _IDEC_flags flags(0);
903 retval.d_raw = __bid128_add(lhs.d_raw, rhs.d_raw, &flags);
904 setErrno(flags);
905 return retval;
906}
907
908 // Subtraction Functions
909
910inline
911DecimalImpUtil_IntelDfp::ValueType32
912DecimalImpUtil_IntelDfp::subtract(DecimalImpUtil_IntelDfp::ValueType32 lhs,
913 DecimalImpUtil_IntelDfp::ValueType32 rhs)
914{
915 DecimalImpUtil_IntelDfp::ValueType32 retval;
916 _IDEC_flags flags(0);
917 retval.d_raw = __bid32_sub(lhs.d_raw, rhs.d_raw, &flags);
918 setErrno(flags);
919 return retval;
920}
921
922inline
923DecimalImpUtil_IntelDfp::ValueType64
924DecimalImpUtil_IntelDfp::subtract(DecimalImpUtil_IntelDfp::ValueType64 lhs,
925 DecimalImpUtil_IntelDfp::ValueType64 rhs)
926{
927 DecimalImpUtil_IntelDfp::ValueType64 retval;
928 _IDEC_flags flags(0);
929 retval.d_raw = __bid64_sub(lhs.d_raw, rhs.d_raw, &flags);
930 setErrno(flags);
931 return retval;
932}
933
934inline
935DecimalImpUtil_IntelDfp::ValueType128
936DecimalImpUtil_IntelDfp::subtract(DecimalImpUtil_IntelDfp::ValueType128 lhs,
937 DecimalImpUtil_IntelDfp::ValueType128 rhs)
938{
939 DecimalImpUtil_IntelDfp::ValueType128 retval;
940 _IDEC_flags flags(0);
941 retval.d_raw = __bid128_sub(lhs.d_raw, rhs.d_raw, &flags);
942 setErrno(flags);
943 return retval;
944}
945
946 // Multiplication Functions
947
948inline
949DecimalImpUtil_IntelDfp::ValueType32
950DecimalImpUtil_IntelDfp::multiply(DecimalImpUtil_IntelDfp::ValueType32 lhs,
951 DecimalImpUtil_IntelDfp::ValueType32 rhs)
952{
953 DecimalImpUtil_IntelDfp::ValueType32 retval;
954 _IDEC_flags flags(0);
955 retval.d_raw = __bid32_mul(lhs.d_raw, rhs.d_raw, &flags);
956 setErrno(flags);
957 return retval;
958}
959
960inline
961DecimalImpUtil_IntelDfp::ValueType64
962DecimalImpUtil_IntelDfp::multiply(DecimalImpUtil_IntelDfp::ValueType64 lhs,
963 DecimalImpUtil_IntelDfp::ValueType64 rhs)
964{
965 DecimalImpUtil_IntelDfp::ValueType64 retval;
966 _IDEC_flags flags(0);
967 retval.d_raw = __bid64_mul(lhs.d_raw, rhs.d_raw, &flags);
968 setErrno(flags);
969 return retval;
970}
971
972inline
973DecimalImpUtil_IntelDfp::ValueType128
974DecimalImpUtil_IntelDfp::multiply(DecimalImpUtil_IntelDfp::ValueType128 lhs,
975 DecimalImpUtil_IntelDfp::ValueType128 rhs)
976{
977 DecimalImpUtil_IntelDfp::ValueType128 retval;
978 _IDEC_flags flags(0);
979 retval.d_raw = __bid128_mul(lhs.d_raw, rhs.d_raw, &flags);
980 setErrno(flags);
981 return retval;
982}
983
984 // Division Functions
985
986inline
987DecimalImpUtil_IntelDfp::ValueType32
988DecimalImpUtil_IntelDfp::divide(DecimalImpUtil_IntelDfp::ValueType32 lhs,
989 DecimalImpUtil_IntelDfp::ValueType32 rhs)
990{
991 DecimalImpUtil_IntelDfp::ValueType32 retval;
992 _IDEC_flags flags(0);
993 retval.d_raw = __bid32_div(lhs.d_raw, rhs.d_raw, &flags);
994 setErrno(flags);
995 return retval;
996}
997
998inline
999DecimalImpUtil_IntelDfp::ValueType64
1000DecimalImpUtil_IntelDfp::divide(DecimalImpUtil_IntelDfp::ValueType64 lhs,
1001 DecimalImpUtil_IntelDfp::ValueType64 rhs)
1002{
1003 DecimalImpUtil_IntelDfp::ValueType64 retval;
1004 _IDEC_flags flags(0);
1005 retval.d_raw = __bid64_div(lhs.d_raw, rhs.d_raw, &flags);
1006 setErrno(flags);
1007 return retval;
1008}
1009
1010inline
1011DecimalImpUtil_IntelDfp::ValueType128
1012DecimalImpUtil_IntelDfp::divide(DecimalImpUtil_IntelDfp::ValueType128 lhs,
1013 DecimalImpUtil_IntelDfp::ValueType128 rhs)
1014{
1015 DecimalImpUtil_IntelDfp::ValueType128 retval;
1016 _IDEC_flags flags(0);
1017 retval.d_raw = __bid128_div(lhs.d_raw, rhs.d_raw, &flags);
1018 setErrno(flags);
1019 return retval;
1020}
1021
1022 // Negation Functions
1023
1024inline
1025DecimalImpUtil_IntelDfp::ValueType32
1026DecimalImpUtil_IntelDfp::negate(DecimalImpUtil_IntelDfp::ValueType32 value)
1027{
1028 DecimalImpUtil_IntelDfp::ValueType32 retval;
1029 retval.d_raw = __bid32_negate(value.d_raw);
1030 return retval;
1031}
1032
1033inline
1034DecimalImpUtil_IntelDfp::ValueType64
1035DecimalImpUtil_IntelDfp::negate(DecimalImpUtil_IntelDfp::ValueType64 value)
1036{
1037 DecimalImpUtil_IntelDfp::ValueType64 retval;
1038 retval.d_raw = __bid64_negate(value.d_raw);
1039 return retval;
1040}
1041
1042inline
1043DecimalImpUtil_IntelDfp::ValueType128
1044DecimalImpUtil_IntelDfp::negate(DecimalImpUtil_IntelDfp::ValueType128 value)
1045{
1046 DecimalImpUtil_IntelDfp::ValueType128 retval;
1047 retval.d_raw = __bid128_negate(value.d_raw);
1048 return retval;
1049}
1050
1051 // Comparison Functions
1052
1053 // Less Than Functions
1054
1055inline
1056bool
1057DecimalImpUtil_IntelDfp::less(DecimalImpUtil_IntelDfp::ValueType32 lhs,
1058 DecimalImpUtil_IntelDfp::ValueType32 rhs)
1059{
1060 _IDEC_flags flags(0);
1061 bool res = __bid32_quiet_less(lhs.d_raw, rhs.d_raw, &flags);
1062 setErrno(flags);
1063 return res;
1064}
1065
1066inline
1067bool
1068DecimalImpUtil_IntelDfp::less(DecimalImpUtil_IntelDfp::ValueType64 lhs,
1069 DecimalImpUtil_IntelDfp::ValueType64 rhs)
1070{
1071 _IDEC_flags flags(0);
1072 bool res = __bid64_quiet_less(lhs.d_raw, rhs.d_raw, &flags);
1073 setErrno(flags);
1074 return res;
1075}
1076
1077inline
1078bool
1079DecimalImpUtil_IntelDfp::less(DecimalImpUtil_IntelDfp::ValueType128 lhs,
1080 DecimalImpUtil_IntelDfp::ValueType128 rhs)
1081{
1082 _IDEC_flags flags(0);
1083 bool res = __bid128_quiet_less(lhs.d_raw, rhs.d_raw, &flags);
1084 setErrno(flags);
1085 return res;
1086}
1087
1088 // Greater Than Functions
1089
1090inline
1091bool
1092DecimalImpUtil_IntelDfp::greater(DecimalImpUtil_IntelDfp::ValueType32 lhs,
1093 DecimalImpUtil_IntelDfp::ValueType32 rhs)
1094{
1095 _IDEC_flags flags(0);
1096 bool res = __bid32_quiet_greater(lhs.d_raw, rhs.d_raw, &flags);
1097 setErrno(flags);
1098 return res;
1099}
1100
1101inline
1102bool DecimalImpUtil_IntelDfp::greater(DecimalImpUtil_IntelDfp::ValueType64 lhs,
1103 DecimalImpUtil_IntelDfp::ValueType64 rhs)
1104{
1105 _IDEC_flags flags(0);
1106 bool res = __bid64_quiet_greater(lhs.d_raw, rhs.d_raw, &flags);
1107 setErrno(flags);
1108 return res;
1109}
1110
1111inline
1112bool
1113DecimalImpUtil_IntelDfp::greater(DecimalImpUtil_IntelDfp::ValueType128 lhs,
1114 DecimalImpUtil_IntelDfp::ValueType128 rhs)
1115{
1116 _IDEC_flags flags(0);
1117 bool res = __bid128_quiet_greater(lhs.d_raw, rhs.d_raw, &flags);
1118 setErrno(flags);
1119 return res;
1120}
1121
1122 // Less Or Equal Functions
1123
1124inline
1125bool
1126DecimalImpUtil_IntelDfp::lessEqual(DecimalImpUtil_IntelDfp::ValueType32 lhs,
1127 DecimalImpUtil_IntelDfp::ValueType32 rhs)
1128{
1129 _IDEC_flags flags(0);
1130 bool res = __bid32_quiet_less_equal(lhs.d_raw, rhs.d_raw, &flags);
1131 setErrno(flags);
1132 return res;
1133}
1134
1135inline
1136bool
1137DecimalImpUtil_IntelDfp::lessEqual(DecimalImpUtil_IntelDfp::ValueType64 lhs,
1138 DecimalImpUtil_IntelDfp::ValueType64 rhs)
1139{
1140 _IDEC_flags flags(0);
1141 bool res = __bid64_quiet_less_equal(lhs.d_raw, rhs.d_raw, &flags);
1142 setErrno(flags);
1143 return res;
1144}
1145
1146inline
1147bool
1148DecimalImpUtil_IntelDfp::lessEqual(DecimalImpUtil_IntelDfp::ValueType128 lhs,
1149 DecimalImpUtil_IntelDfp::ValueType128 rhs)
1150{
1151 _IDEC_flags flags(0);
1152 bool res = __bid128_quiet_less_equal(lhs.d_raw, rhs.d_raw, &flags);
1153 setErrno(flags);
1154 return res;
1155}
1156
1157 // Greater Or Equal Functions
1158
1159inline
1160bool
1161DecimalImpUtil_IntelDfp::greaterEqual(DecimalImpUtil_IntelDfp::ValueType32 lhs,
1162 DecimalImpUtil_IntelDfp::ValueType32 rhs)
1163{
1164 _IDEC_flags flags(0);
1165 bool res = __bid32_quiet_greater_equal(lhs.d_raw, rhs.d_raw, &flags);
1166 setErrno(flags);
1167 return res;
1168}
1169
1170inline
1171bool
1172DecimalImpUtil_IntelDfp::greaterEqual(DecimalImpUtil_IntelDfp::ValueType64 lhs,
1173 DecimalImpUtil_IntelDfp::ValueType64 rhs)
1174{
1175 _IDEC_flags flags(0);
1176 bool res = __bid64_quiet_greater_equal(lhs.d_raw, rhs.d_raw, &flags);
1177 setErrno(flags);
1178 return res;
1179}
1180
1181inline
1182bool
1183DecimalImpUtil_IntelDfp::greaterEqual(
1184 DecimalImpUtil_IntelDfp::ValueType128 lhs,
1185 DecimalImpUtil_IntelDfp::ValueType128 rhs)
1186{
1187 _IDEC_flags flags(0);
1188 bool res = __bid128_quiet_greater_equal(lhs.d_raw, rhs.d_raw, &flags);
1189 setErrno(flags);
1190 return res;
1191}
1192
1193 // Equality Functions
1194
1195inline
1196bool
1197DecimalImpUtil_IntelDfp::equal(DecimalImpUtil_IntelDfp::ValueType32 lhs,
1198 DecimalImpUtil_IntelDfp::ValueType32 rhs)
1199{
1200 _IDEC_flags flags(0);
1201 bool res = __bid32_quiet_equal(lhs.d_raw, rhs.d_raw, &flags);
1202 setErrno(flags);
1203 return res;
1204}
1205
1206inline
1207bool
1208DecimalImpUtil_IntelDfp::equal(DecimalImpUtil_IntelDfp::ValueType64 lhs,
1209 DecimalImpUtil_IntelDfp::ValueType64 rhs)
1210{
1211 _IDEC_flags flags(0);
1212 bool res = __bid64_quiet_equal(lhs.d_raw, rhs.d_raw, &flags);
1213 setErrno(flags);
1214 return res;
1215}
1216
1217inline
1218bool
1219DecimalImpUtil_IntelDfp::equal(DecimalImpUtil_IntelDfp::ValueType128 lhs,
1220 DecimalImpUtil_IntelDfp::ValueType128 rhs)
1221{
1222 _IDEC_flags flags(0);
1223 bool res = __bid128_quiet_equal(lhs.d_raw, rhs.d_raw, &flags);
1224 setErrno(flags);
1225 return res;
1226}
1227
1228 // Inequality Functions
1229
1230inline
1231bool
1232DecimalImpUtil_IntelDfp::notEqual(DecimalImpUtil_IntelDfp::ValueType32 lhs,
1233 DecimalImpUtil_IntelDfp::ValueType32 rhs)
1234{
1235 _IDEC_flags flags(0);
1236 bool res = __bid32_quiet_not_equal(lhs.d_raw, rhs.d_raw, &flags);
1237 setErrno(flags);
1238 return res;
1239}
1240
1241inline
1242bool
1243DecimalImpUtil_IntelDfp::notEqual(DecimalImpUtil_IntelDfp::ValueType64 lhs,
1244 DecimalImpUtil_IntelDfp::ValueType64 rhs)
1245{
1246 _IDEC_flags flags(0);
1247 bool res = __bid64_quiet_not_equal(lhs.d_raw, rhs.d_raw, &flags);
1248 setErrno(flags);
1249 return res;
1250}
1251
1252inline
1253bool
1254DecimalImpUtil_IntelDfp::notEqual(DecimalImpUtil_IntelDfp::ValueType128 lhs,
1255 DecimalImpUtil_IntelDfp::ValueType128 rhs)
1256{
1257 _IDEC_flags flags(0);
1258 bool res = __bid128_quiet_not_equal(lhs.d_raw, rhs.d_raw, &flags);
1259 setErrno(flags);
1260 return res;
1261}
1262
1263 // Inter-type Conversion functions
1264
1265inline
1266DecimalImpUtil_IntelDfp::ValueType32
1267DecimalImpUtil_IntelDfp::convertToDecimal32(
1268 const DecimalImpUtil_IntelDfp::ValueType64& input)
1269{
1270 DecimalImpUtil_IntelDfp::ValueType32 retval;
1271 _IDEC_flags flags(0);
1272 retval.d_raw = __bid64_to_bid32(input.d_raw, &flags);
1273 setErrno(flags);
1274 return retval;
1275}
1276
1277inline
1278DecimalImpUtil_IntelDfp::ValueType32
1279DecimalImpUtil_IntelDfp::convertToDecimal32(
1280 const DecimalImpUtil_IntelDfp::ValueType128& input)
1281{
1282 DecimalImpUtil_IntelDfp::ValueType32 retval;
1283 _IDEC_flags flags(0);
1284 retval.d_raw = __bid128_to_bid32(input.d_raw, &flags);
1285 setErrno(flags);
1286 return retval;
1287}
1288
1289inline
1290DecimalImpUtil_IntelDfp::ValueType64
1291DecimalImpUtil_IntelDfp::convertToDecimal64(
1292 const DecimalImpUtil_IntelDfp::ValueType32& input)
1293{
1294 DecimalImpUtil_IntelDfp::ValueType64 retval;
1295 _IDEC_flags flags(0);
1296 retval.d_raw = __bid32_to_bid64(input.d_raw, &flags);
1297 setErrno(flags);
1298 return retval;
1299}
1300
1301inline
1302DecimalImpUtil_IntelDfp::ValueType64
1303DecimalImpUtil_IntelDfp::convertToDecimal64(
1304 const DecimalImpUtil_IntelDfp::ValueType128& input)
1305{
1306 DecimalImpUtil_IntelDfp::ValueType64 retval;
1307 _IDEC_flags flags(0);
1308 retval.d_raw = __bid128_to_bid64(input.d_raw, &flags);
1309 setErrno(flags);
1310 return retval;
1311}
1312
1313inline
1314DecimalImpUtil_IntelDfp::ValueType128
1315DecimalImpUtil_IntelDfp::convertToDecimal128(
1316 const DecimalImpUtil_IntelDfp::ValueType32& input)
1317{
1318 DecimalImpUtil_IntelDfp::ValueType128 retval;
1319 _IDEC_flags flags(0);
1320 retval.d_raw = __bid32_to_bid128(input.d_raw, &flags);
1321 setErrno(flags);
1322 return retval;
1323}
1324
1325inline
1326DecimalImpUtil_IntelDfp::ValueType128
1327DecimalImpUtil_IntelDfp::convertToDecimal128(
1328 const DecimalImpUtil_IntelDfp::ValueType64& input)
1329{
1330 DecimalImpUtil_IntelDfp::ValueType128 retval;
1331 _IDEC_flags flags(0);
1332 retval.d_raw = __bid64_to_bid128(input.d_raw, &flags);
1333 setErrno(flags);
1334 return retval;
1335}
1336
1337 // Binary floating point conversion functions
1338
1339inline
1340DecimalImpUtil_IntelDfp::ValueType32
1341DecimalImpUtil_IntelDfp::binaryToDecimal32(float value)
1342{
1343 ValueType32 result;
1344 _IDEC_flags flags(0);
1345 result.d_raw = __binary32_to_bid32(value, &flags);
1346 setErrno(flags);
1347 return result;
1348}
1349
1350inline
1351DecimalImpUtil_IntelDfp::ValueType32
1352DecimalImpUtil_IntelDfp::binaryToDecimal32(double value)
1353{
1354 ValueType32 result;
1355 _IDEC_flags flags(0);
1356 result.d_raw = __binary64_to_bid32(value, &flags);
1357 setErrno(flags);
1358 return result;
1359}
1360
1361inline
1362DecimalImpUtil_IntelDfp::ValueType64
1363DecimalImpUtil_IntelDfp::binaryToDecimal64(float value)
1364{
1365 ValueType64 result;
1366 _IDEC_flags flags(0);
1367 result.d_raw = __binary32_to_bid64(value, &flags);
1368 setErrno(flags);
1369 return result;
1370}
1371
1372inline
1373DecimalImpUtil_IntelDfp::ValueType64
1374DecimalImpUtil_IntelDfp::binaryToDecimal64(double value)
1375{
1376 ValueType64 result;
1377 _IDEC_flags flags(0);
1378 result.d_raw = __binary64_to_bid64(value, &flags);
1379 setErrno(flags);
1380 return result;
1381}
1382
1383inline
1384DecimalImpUtil_IntelDfp::ValueType128
1385DecimalImpUtil_IntelDfp::binaryToDecimal128(float value)
1386{
1387 ValueType128 result;
1388 _IDEC_flags flags(0);
1389 result.d_raw = __binary32_to_bid128(value, &flags);
1390 setErrno(flags);
1391 return result;
1392}
1393
1394inline
1395DecimalImpUtil_IntelDfp::ValueType128
1396DecimalImpUtil_IntelDfp::binaryToDecimal128(double value)
1397{
1398 ValueType128 result;
1399 _IDEC_flags flags(0);
1400 result.d_raw = __binary64_to_bid128(value, &flags);
1401 setErrno(flags);
1402 return result;
1403}
1404
1405 // makeDecimalRaw Functions
1406
1407inline
1408DecimalImpUtil_IntelDfp::ValueType32
1409DecimalImpUtil_IntelDfp::makeDecimalRaw32(int significand,
1410 int exponent)
1411{
1412 DecimalImpUtil_IntelDfp::ValueType32 result;
1413 result = DecimalImpUtil_IntelDfp::int32ToDecimal32(significand);
1414 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1415 return result;
1416}
1417
1418inline
1419DecimalImpUtil_IntelDfp::ValueType64
1420DecimalImpUtil_IntelDfp::makeDecimalRaw64(unsigned long long significand,
1421 int exponent)
1422{
1423 DecimalImpUtil_IntelDfp::ValueType64 result;
1424 result = DecimalImpUtil_IntelDfp::uint64ToDecimal64(significand);
1425 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1426 return result;
1427}
1428
1429inline
1430DecimalImpUtil_IntelDfp::ValueType64
1431DecimalImpUtil_IntelDfp::makeDecimalRaw64(long long significand,
1432 int exponent)
1433{
1434 DecimalImpUtil_IntelDfp::ValueType64 result;
1435 result = DecimalImpUtil_IntelDfp::int64ToDecimal64(significand);
1436 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1437 return result;
1438}
1439
1440inline
1441DecimalImpUtil_IntelDfp::ValueType64
1442DecimalImpUtil_IntelDfp::makeDecimalRaw64(unsigned int significand,
1443 int exponent)
1444{
1445 DecimalImpUtil_IntelDfp::ValueType64 result;
1446 result = DecimalImpUtil_IntelDfp::uint32ToDecimal64(significand);
1447 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1448 return result;
1449}
1450
1451inline
1452DecimalImpUtil_IntelDfp::ValueType64
1453DecimalImpUtil_IntelDfp::makeDecimalRaw64(int significand,
1454 int exponent)
1455{
1456 DecimalImpUtil_IntelDfp::ValueType64 result;
1457 result = DecimalImpUtil_IntelDfp::int32ToDecimal64(significand);
1458 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1459 return result;
1460}
1461
1462inline
1463DecimalImpUtil_IntelDfp::ValueType128
1464DecimalImpUtil_IntelDfp::makeDecimalRaw128(unsigned long long significand,
1465 int exponent)
1466{
1467 DecimalImpUtil_IntelDfp::ValueType128 result;
1468 result = DecimalImpUtil_IntelDfp::uint64ToDecimal128(significand);
1469 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1470 return result;
1471}
1472
1473inline
1474DecimalImpUtil_IntelDfp::ValueType128
1475DecimalImpUtil_IntelDfp::makeDecimalRaw128(long long significand,
1476 int exponent)
1477{
1478 DecimalImpUtil_IntelDfp::ValueType128 result;
1479 result = DecimalImpUtil_IntelDfp::int64ToDecimal128(significand);
1480 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1481 return result;
1482}
1483
1484inline
1485DecimalImpUtil_IntelDfp::ValueType128
1486DecimalImpUtil_IntelDfp::makeDecimalRaw128(unsigned int significand,
1487 int exponent)
1488{
1489 DecimalImpUtil_IntelDfp::ValueType128 result;
1490 result = DecimalImpUtil_IntelDfp::uint32ToDecimal128(significand);
1491 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1492 return result;
1493}
1494
1495inline
1496DecimalImpUtil_IntelDfp::ValueType128
1497DecimalImpUtil_IntelDfp::makeDecimalRaw128(int significand,
1498 int exponent)
1499{
1500 DecimalImpUtil_IntelDfp::ValueType128 result;
1501 result = DecimalImpUtil_IntelDfp::int32ToDecimal128(significand);
1502 result = DecimalImpUtil_IntelDfp::scaleB(result, exponent);
1503 return result;
1504}
1505
1506 // IEEE Scale B Functions
1507
1508inline
1509DecimalImpUtil_IntelDfp::ValueType32
1510DecimalImpUtil_IntelDfp::scaleB(DecimalImpUtil_IntelDfp::ValueType32 value,
1511 int exponent)
1512{
1513 DecimalImpUtil_IntelDfp::ValueType32 result;
1514 _IDEC_flags flags(0);
1515 result.d_raw = __bid32_scalbn(value.d_raw, exponent, &flags);
1516 return result;
1517}
1518
1519inline
1520DecimalImpUtil_IntelDfp::ValueType64
1521DecimalImpUtil_IntelDfp::scaleB(DecimalImpUtil_IntelDfp::ValueType64 value,
1522 int exponent)
1523{
1524 DecimalImpUtil_IntelDfp::ValueType64 result;
1525 _IDEC_flags flags(0);
1526 result.d_raw = __bid64_scalbn(value.d_raw, exponent, &flags);
1527 return result;
1528}
1529
1530inline
1531DecimalImpUtil_IntelDfp::ValueType128
1532DecimalImpUtil_IntelDfp::scaleB(DecimalImpUtil_IntelDfp::ValueType128 value,
1533 int exponent)
1534{
1535 DecimalImpUtil_IntelDfp::ValueType128 result;
1536 _IDEC_flags flags(0);
1537 result.d_raw = __bid128_scalbn(value.d_raw, exponent, &flags);
1538 return result;
1539}
1540
1541 // Parsing functions
1542
1543inline
1544DecimalImpUtil_IntelDfp::ValueType32
1545DecimalImpUtil_IntelDfp::parse32(const char *string)
1546{
1547 DecimalImpUtil_IntelDfp::ValueType32 result;
1548 _IDEC_flags flags(0);
1549 // NOTE: It is probably safe to convert from a 'const char *' to a 'char *'
1550 // because the __bid* interfaces are C interfaces.
1551 result.d_raw = __bid32_from_string(const_cast<char *>(string), &flags);
1552
1553 if (BID_OVERFLOW_EXCEPTION & flags ||
1554 BID_UNDERFLOW_EXCEPTION & flags)
1555 {
1556 errno = ERANGE;
1557 }
1558
1559 return result;
1560}
1561
1562
1563inline
1564DecimalImpUtil_IntelDfp::ValueType64
1565DecimalImpUtil_IntelDfp::parse64(const char *string)
1566{
1567 DecimalImpUtil_IntelDfp::ValueType64 result;
1568 _IDEC_flags flags(0);
1569 // NOTE: It is probably safe to convert from a 'const char *' to a 'char *'
1570 // because the __bid* interfaces are C interfaces.
1571 result.d_raw = __bid64_from_string(const_cast<char *>(string), &flags);
1572
1573 if (BID_OVERFLOW_EXCEPTION & flags ||
1574 BID_UNDERFLOW_EXCEPTION & flags)
1575 {
1576 errno = ERANGE;
1577 }
1578
1579 return result;
1580}
1581
1582inline
1583DecimalImpUtil_IntelDfp::ValueType128
1584DecimalImpUtil_IntelDfp::parse128(const char *string)
1585{
1586 DecimalImpUtil_IntelDfp::ValueType128 result;
1587 _IDEC_flags flags(0);
1588 // NOTE: It is probably safe to convert from a 'const char *' to a 'char *'
1589 // because the __bid* interfaces are C interfaces.
1590 result.d_raw = __bid128_from_string(const_cast<char *>(string), &flags);
1591
1592 if (BID_OVERFLOW_EXCEPTION & flags ||
1593 BID_UNDERFLOW_EXCEPTION & flags)
1594 {
1595 errno = ERANGE;
1596 }
1597
1598 return result;
1599}
1600
1601
1602inline
1603DecimalImpUtil_IntelDfp::ValueType32
1604DecimalImpUtil_IntelDfp::parse32(const char *string, unsigned int *status)
1605{
1606 BSLS_ASSERT(0 == *status);
1607
1608 DecimalImpUtil_IntelDfp::ValueType32 result;
1610
1611 // NOTE: It is probably safe to convert from a 'const char *' to a 'char *'
1612 // because the __bid* interfaces are C interfaces. Also note that inexact,
1613 // underflow, and overflow are the only dcoumented floating point
1614 // exceptions for this function.
1615
1616 result.d_raw = __bid32_from_string(const_cast<char *>(string), status);
1617
1618 return result;
1619}
1620
1621
1622inline
1623DecimalImpUtil_IntelDfp::ValueType64
1624DecimalImpUtil_IntelDfp::parse64(const char *string, unsigned int *status)
1625{
1626 BSLS_ASSERT(0 == *status);
1627
1628 DecimalImpUtil_IntelDfp::ValueType64 result;
1629
1631
1632 // NOTE: It is probably safe to convert from a 'const char *' to a 'char *'
1633 // because the __bid* interfaces are C interfaces. Also note that inexact,
1634 // underflow, and overflow are the only dcoumented floating point
1635 // exceptions for this function.
1636
1637 result.d_raw = __bid64_from_string(const_cast<char *>(string), status);
1638
1639 return result;
1640}
1641
1642inline
1643DecimalImpUtil_IntelDfp::ValueType128
1644DecimalImpUtil_IntelDfp::parse128(const char *string, unsigned int *status)
1645{
1646 BSLS_ASSERT(0 == *status);
1647
1648 DecimalImpUtil_IntelDfp::ValueType128 result;
1650
1651 // NOTE: It is probably safe to convert from a 'const char *' to a 'char *'
1652 // because the __bid* interfaces are C interfaces. Also note that inexact,
1653 // underflow, and overflow are the only dcoumented floating point
1654 // exceptions for this function.
1655
1656 result.d_raw = __bid128_from_string(const_cast<char *>(string), status);
1657
1658 return result;
1659}
1660
1661 // Densely Packed Conversion Functions
1662inline
1663DecimalImpUtil_IntelDfp::ValueType32
1664DecimalImpUtil_IntelDfp::convertDPDtoBID(DecimalStorage::Type32 dpd)
1665{
1666 ValueType32 value;
1667 bsl::memcpy(&value, &dpd, sizeof(value));
1668
1669 ValueType32 result;
1670 result.d_raw = __bid_dpd_to_bid32(value.d_raw);
1671
1672 return result;
1673}
1674
1675inline
1676DecimalImpUtil_IntelDfp::ValueType64
1677DecimalImpUtil_IntelDfp::convertDPDtoBID(DecimalStorage::Type64 dpd)
1678{
1679 ValueType64 value;
1680 bsl::memcpy(&value, &dpd, sizeof(value));
1681
1682 ValueType64 result;
1683 result.d_raw = __bid_dpd_to_bid64(value.d_raw);
1684
1685 return result;
1686}
1687
1688inline
1689DecimalImpUtil_IntelDfp::ValueType128
1690DecimalImpUtil_IntelDfp::convertDPDtoBID(DecimalStorage::Type128 dpd)
1691{
1692 ValueType128 value;
1693 bsl::memcpy(&value, &dpd, sizeof(value));
1694
1695 ValueType128 result;
1696 result.d_raw = __bid_dpd_to_bid128(value.d_raw);
1697
1698 return result;
1699}
1700
1701inline
1703DecimalImpUtil_IntelDfp::convertBIDtoDPD(
1704 DecimalImpUtil_IntelDfp::ValueType32 value)
1705{
1706 ValueType32 result;
1707 result.d_raw = __bid_to_dpd32(value.d_raw);
1708
1710 bsl::memcpy(&dpd, &result, sizeof(dpd));
1711
1712 return dpd;
1713}
1714
1715inline
1717DecimalImpUtil_IntelDfp::convertBIDtoDPD(
1718 DecimalImpUtil_IntelDfp::ValueType64 value)
1719{
1720 ValueType64 result;
1721 result.d_raw = __bid_to_dpd64(value.d_raw);
1722
1724 bsl::memcpy(&dpd, &result, sizeof(dpd));
1725
1726 return dpd;
1727}
1728
1729inline
1731DecimalImpUtil_IntelDfp::convertBIDtoDPD(
1732 DecimalImpUtil_IntelDfp::ValueType128 value)
1733{
1734 ValueType128 result;
1735 result.d_raw = __bid_to_dpd128(value.d_raw);
1736
1738 bsl::memcpy(&dpd, &result, sizeof(dpd));
1739
1740 return dpd;
1741}
1742 // Binary Integral Conversion Functions
1743
1744inline
1745DecimalImpUtil_IntelDfp::ValueType32
1746DecimalImpUtil_IntelDfp::convertFromBID(DecimalStorage::Type32 bid)
1747{
1748 ValueType32 result;
1749 bsl::memcpy(&result, &bid, sizeof(result));
1750
1751 return result;
1752}
1753
1754inline
1755DecimalImpUtil_IntelDfp::ValueType64
1756DecimalImpUtil_IntelDfp::convertFromBID(DecimalStorage::Type64 bid)
1757{
1758 ValueType64 result;
1759 bsl::memcpy(&result, &bid, sizeof(result));
1760
1761 return result;
1762}
1763
1764inline
1765DecimalImpUtil_IntelDfp::ValueType128
1766DecimalImpUtil_IntelDfp::convertFromBID(DecimalStorage::Type128 bid)
1767{
1768 ValueType128 result;
1769 bsl::memcpy(&result, &bid, sizeof(result));
1770
1771 return result;
1772}
1773
1774inline
1776DecimalImpUtil_IntelDfp::convertToBID(
1777 DecimalImpUtil_IntelDfp::ValueType32 value)
1778{
1780 bsl::memcpy(&bid, &value, sizeof(bid));
1781
1782 return bid;
1783}
1784
1785inline
1787DecimalImpUtil_IntelDfp::convertToBID(
1788 DecimalImpUtil_IntelDfp::ValueType64 value)
1789{
1791 bsl::memcpy(&bid, &value, sizeof(bid));
1792
1793 return bid;
1794}
1795
1796inline
1798DecimalImpUtil_IntelDfp::convertToBID(
1799 DecimalImpUtil_IntelDfp::ValueType128 value)
1800{
1802 bsl::memcpy(&bid, &value, sizeof(bid));
1803
1804 return bid;
1805}
1806
1807} // close package namespace
1808
1809
1810#endif // #ifdef BDLDFP_DECIMALPLATFORM_INTELDFP
1811
1812#endif
1813
1814// ----------------------------------------------------------------------------
1815// Copyright 2014 Bloomberg Finance L.P.
1816//
1817// Licensed under the Apache License, Version 2.0 (the "License");
1818// you may not use this file except in compliance with the License.
1819// You may obtain a copy of the License at
1820//
1821// http://www.apache.org/licenses/LICENSE-2.0
1822//
1823// Unless required by applicable law or agreed to in writing, software
1824// distributed under the License is distributed on an "AS IS" BASIS,
1825// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1826// See the License for the specific language governing permissions and
1827// limitations under the License.
1828// ----------------------------- END-OF-FILE ----------------------------------
1829
1830/** @} */
1831/** @} */
1832/** @} */
#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