Format a floating-point scalar as a decimal string in scientific notation.
Provides control over rounding, trimming and padding. Uses and assumes IEEE unbiased rounding. Uses the “Dragon4” algorithm.
Value to format.
Maximum number of digits to print. May be None if unique
is True, but must be an integer if unique is False.
If True, use a digit-generation strategy which gives the shortest representation which uniquely identifies the floating-point number from other values of the same type, by judicious rounding. If precision is given fewer digits than necessary can be printed. If min_digits is given more can be printed, in which cases the last digit is rounded with unbiased rounding. If False, digits are generated as if printing an infinite-precision value and stopping after precision digits, rounding the remaining value with unbiased rounding
Controls post-processing trimming of trailing digits, as follows:
‘k’ : keep trailing zeros, keep decimal point (no trimming)
‘.’ : trim all trailing zeros, leave decimal point
‘0’ : trim all but the zero before the decimal point. Insert the zero if it is missing.
‘-’ : trim trailing zeros and any trailing decimal point
Whether to show the sign for positive values.
Pad the left side of the string with whitespace until at least that many characters are to the left of the decimal point.
Pad the exponent with zeros until it contains at least this many digits. If omitted, the exponent will be at least 2 digits.
Minimum number of digits to print. This only has an effect for unique=True. In that case more digits than necessary to uniquely identify the value may be printed and rounded unbiased.
New in version 1.21.0.
The string representation of the floating point value
Examples
>>> import numpy as np >>> np.format_float_scientific(np.float32(np.pi)) '3.1415927e+00' >>> s = np.float32(1.23e24) >>> np.format_float_scientific(s, unique=False, precision=15) '1.230000071797338e+24' >>> np.format_float_scientific(s, exp_digits=4) '1.23e+0024'
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4