[#BloombergLP-bdldfp-DecimalUtil-quantizeEqual-02] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdldfp.adoc[bdldfp]::xref:BloombergLP/bdldfp/DecimalUtil.adoc[DecimalUtil]::quantizeEqual :relfileprefix: ../../../ :mrdocs: Set `x` to `y` with the specified `exponent` if that value is exact. == Synopsis Declared in `<bdldfp_decimalutil.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- static int quantizeEqual( xref:BloombergLP/bdldfp/Decimal32.adoc[Decimal32]* x, xref:BloombergLP/bdldfp/Decimal32.adoc[Decimal32] y, int exponent); ---- == Description If a floating‐point number equal to the specified `y` and having the specified `exponent` can be constructed, set that value into the specified `x` and return 0. Otherwise, or if `y` is NaN or infinity, leave the contents of `x` unchanged and return a non‐zero value. The behavior is undefined unless `exponent` satisfies the following conditions * for `Decimal32` type: `‐101 <= exponent <= 90` * for `Decimal64` type: `‐398 <= exponent <= 369` * for `Decimal128` type: `‐6176 <= exponent <= 6111` Example: `Decimal32 x;` `BSLS_ASSERT(0 == quantizeEqual(&x, 123e+3_d32, 2);` `BSLS_ASSERT(1230e+2_d32 == x);` `BSLS_ASSERT(0 != quantizeEqual(&x, 123e+3_d32, ‐2);` `BSLS_ASSERT(1230e+2_d32 == x);` == Return Value 0 on success and a non‐zero value otherwise == Parameters [cols="1,4"] |=== | Name| Description | *x* | receives the quantized value on success | *y* | value to quantize into `x` | *exponent* | desired decimal exponent |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#