[#BloombergLP-bdldfp-DecimalConvertUtil-decimalToFloat-04] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdldfp.adoc[bdldfp]::xref:BloombergLP/bdldfp/DecimalConvertUtil.adoc[DecimalConvertUtil]::decimalToFloat :relfileprefix: ../../../ :mrdocs: Return a `float` object having the value closest to the value of the specified `decimal` object following the conversion rules defined by IEEE‐754: == Synopsis Declared in `<bdldfp_decimalconvertutil.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- static float decimalToFloat(xref:BloombergLP/bdldfp/Decimal32.adoc[Decimal32] decimal); ---- == Description * If the `decimal` object is a NaN, return a NaN. * Otherwise if `decimal` is positive or negative infinity, return infinity of the same sign. * Otherwise if `decimal` is positive or negative zero, return zero of the same sign. * Otherwise if `decimal` object has an absolute value that is larger than `std::numeric_limits<long double>::max()`, raise the "overflow" floating‐point exception and return infinity of the same sign as `decimal`. * Otherwise if `decimal` has an absolute value that is smaller than `std::numeric_limits<float>::min()`, raise the "underflow" floating‐point exception and return zero of the same sign as `decimal`. * Otherwise if `decimal` has a value that has more significant base‐10 digits than `std::numeric_limits<float>::digits10`, raise the "inexact" floating‐point exception, round that value according to the _binary_ rounding direction setting of the floating‐point environment, and return the result of that. * Otherwise if `decimal` has a significand that cannot be exactly represented using binary floating‐point, raise the "inexact" floating‐point exception, round that value according to the _binary_ rounding direction setting of the environment, and return the result of that. * Otherwise use the exact value of the `other` object for the initialization if this object. [.small]#Created with https://www.mrdocs.com[MrDocs]#