[#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&period;

== Synopsis

Declared in `&lt;bdldfp&lowbar;decimalutil&period;h&gt;`

[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&hyphen;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&period; Otherwise, or if `y` is NaN or infinity, leave the contents of `x` unchanged and return a non&hyphen;zero value&period; The behavior is undefined unless `exponent` satisfies the following conditions &ast; for `Decimal32` type&colon; `&hyphen;101 &lt;&equals; exponent &lt;&equals; 90` &ast; for `Decimal64` type&colon; `&hyphen;398 &lt;&equals; exponent &lt;&equals; 369` &ast; for `Decimal128` type&colon; `&hyphen;6176 &lt;&equals; exponent &lt;&equals; 6111`

Example&colon; `Decimal32 x&semi;` `BSLS&lowbar;ASSERT(0 &equals;&equals; quantizeEqual(&amp;x, 123e&plus;3&lowbar;d32, 2)&semi;` `BSLS&lowbar;ASSERT(1230e&plus;2&lowbar;d32 &equals;&equals; x)&semi;` `BSLS&lowbar;ASSERT(0 !&equals; quantizeEqual(&amp;x, 123e&plus;3&lowbar;d32, &hyphen;2)&semi;` `BSLS&lowbar;ASSERT(1230e&plus;2&lowbar;d32 &equals;&equals; x)&semi;`

== Return Value

0 on success and a non&hyphen;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]#
