[#BloombergLP-bdldfp-DecimalConvertUtil-decimal128FromFloat] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdldfp.adoc[bdldfp]::xref:BloombergLP/bdldfp/DecimalConvertUtil.adoc[DecimalConvertUtil]::decimal128FromFloat :relfileprefix: ../../../ :mrdocs: Return a decimal floating‐point number converted from the specified `binary`. == Synopsis Declared in `<bdldfp_decimalconvertutil.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- static xref:BloombergLP/bdldfp/Decimal128.adoc[Decimal128] decimal128FromFloat( float binary, int digits = 0); ---- == Description If `binary` is singular (+/‐NaN, +/‐Inf, or +/‐0) or is not within the representable range of the return type, return a corresponding decimal singular value. Optionally specify `digits` to indicate the number of significant digits to produce in the returned value. The `digits` parameter is treated as follows: If `digits` is larger than the number of digits in the destination type, it will be reduced to that number of digits. If `digits` is positive, the result is `binary` rounded to that many significant digits. If `digits` is negative, the decimal value with the fewest significant digits that converts back to `binary` is returned if possible, and otherwise the value closest to `binary` is returned. Note that this provides the most visually appealing result but is the most expensive to compute. If `digits` is not specified or 0, a default value will be used (possibly depending on the value of `binary`) based on the premise that `binary` is a converted decimal value of no more significant digits than is guaranteed to have a uniquely converted binary value (15 for `double`, 6 for `float` in general, and 7 for `float` in the range `[ .0009999995 .. 8589972000 ]`). Note that this is likely to have the best performance for "business" numbers (i.e., numbers that originate as decimal values in external market quote feeds). Note that the purpose of these functions is to restore a decimal value that has been converted to a binary floating‐point type. It is more efficient to use conversion constructors when all that is needed is the nearest decimal to the `binary` value. Note that if `binary` is a `float` value that was converted from an IBM/Perkin‐Elmer/Interdata binary `float` value itself converted from a decimal value of no more than 6 significant digits, specifying 6 for `digits` will recover the original decimal value. Not specifying `digits` may result in a value having a spurious seventh digit. [.small]#Created with https://www.mrdocs.com[MrDocs]#