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