numpy 1.22.4 Pypi GitHub Homepage
Other Docs
ParametersReturnsBackRef
format_float_positional(x, precision=None, unique=True, fractional=True, trim='k', sign=False, pad_left=None, pad_right=None, min_digits=None)

Provides control over rounding, trimming and padding. Uses and assumes IEEE unbiased rounding. Uses the "Dragon4" algorithm.

Parameters

x : python float or numpy floating scalar

Value to format.

precision : non-negative integer or None, optional

Maximum number of digits to print. May be None if unique is :None:None:`True`, but must be an integer if unique is :None:None:`False`.

unique : boolean, optional

If :None:None:`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 :None:None:`precision` is given fewer digits than necessary can be printed, or if :None:None:`min_digits` is given more can be printed, in which cases the last digit is rounded with unbiased rounding. If :None:None:`False`, digits are generated as if printing an infinite-precision value and stopping after :None:None:`precision` digits, rounding the remaining value with unbiased rounding

fractional : boolean, optional

If :None:None:`True`, the cutoffs of :None:None:`precision` and :None:None:`min_digits` refer to the total number of digits after the decimal point, including leading zeros. If :None:None:`False`, :None:None:`precision` and :None:None:`min_digits` refer to the total number of significant digits, before or after the decimal point, ignoring leading zeros.

trim : one of 'k', '.', '0', '-', optional

Controls post-processing trimming of trailing digits, as follows:

sign : boolean, optional

Whether to show the sign for positive values.

pad_left : non-negative integer, optional

Pad the left side of the string with whitespace until at least that many characters are to the left of the decimal point.

pad_right : non-negative integer, optional

Pad the right side of the string with whitespace until at least that many characters are to the right of the decimal point.

min_digits : non-negative integer or None, optional

Minimum number of digits to print. Only has an effect if :None:None:`unique=True` in which case additional digits past those necessary to uniquely identify the value may be printed, rounding the last additional digit.

-- versionadded:: 1.21.0

Returns

rep : string

The string representation of the floating point value

Format a floating-point scalar as a decimal string in positional notation.

See Also

format_float_scientific

Examples

>>> np.format_float_positional(np.float32(np.pi))
'3.1415927'
>>> np.format_float_positional(np.float16(np.pi))
'3.14'
>>> np.format_float_positional(np.float16(0.3))
'0.3'
>>> np.format_float_positional(np.float16(0.3), unique=False, precision=10)
'0.3000488281'
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

numpy.core._multiarray_tests.format_float_OSprintf_g numpy.format_float_scientific

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /numpy/core/arrayprint.py#1130
type: <class 'function'>
Commit: