MCPcopy Create free account
hub / github.com/numpy/numpy / format_float_scientific

Function format_float_scientific

numpy/core/arrayprint.py:1051–1127  ·  view source on GitHub ↗

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. Parameters ---------- x : python float or numpy floating scalar V

(x, precision=None, unique=True, trim='k',
                            sign=False, pad_left=None, exp_digits=None,
                            min_digits=None)

Source from the content-addressed store, hash-verified

1049
1050@set_module('numpy')
1051def format_float_scientific(x, precision=None, unique=True, trim='k',
1052 sign=False, pad_left=None, exp_digits=None,
1053 min_digits=None):
1054 """
1055 Format a floating-point scalar as a decimal string in scientific notation.
1056
1057 Provides control over rounding, trimming and padding. Uses and assumes
1058 IEEE unbiased rounding. Uses the "Dragon4" algorithm.
1059
1060 Parameters
1061 ----------
1062 x : python float or numpy floating scalar
1063 Value to format.
1064 precision : non-negative integer or None, optional
1065 Maximum number of digits to print. May be None if `unique` is
1066 `True`, but must be an integer if unique is `False`.
1067 unique : boolean, optional
1068 If `True`, use a digit-generation strategy which gives the shortest
1069 representation which uniquely identifies the floating-point number from
1070 other values of the same type, by judicious rounding. If `precision`
1071 is given fewer digits than necessary can be printed. If `min_digits`
1072 is given more can be printed, in which cases the last digit is rounded
1073 with unbiased rounding.
1074 If `False`, digits are generated as if printing an infinite-precision
1075 value and stopping after `precision` digits, rounding the remaining
1076 value with unbiased rounding
1077 trim : one of 'k', '.', '0', '-', optional
1078 Controls post-processing trimming of trailing digits, as follows:
1079
1080 * 'k' : keep trailing zeros, keep decimal point (no trimming)
1081 * '.' : trim all trailing zeros, leave decimal point
1082 * '0' : trim all but the zero before the decimal point. Insert the
1083 zero if it is missing.
1084 * '-' : trim trailing zeros and any trailing decimal point
1085 sign : boolean, optional
1086 Whether to show the sign for positive values.
1087 pad_left : non-negative integer, optional
1088 Pad the left side of the string with whitespace until at least that
1089 many characters are to the left of the decimal point.
1090 exp_digits : non-negative integer, optional
1091 Pad the exponent with zeros until it contains at least this many digits.
1092 If omitted, the exponent will be at least 2 digits.
1093 min_digits : non-negative integer or None, optional
1094 Minimum number of digits to print. This only has an effect for
1095 `unique=True`. In that case more digits than necessary to uniquely
1096 identify the value may be printed and rounded unbiased.
1097
1098 -- versionadded:: 1.21.0
1099
1100 Returns
1101 -------
1102 rep : string
1103 The string representation of the floating point value
1104
1105 See Also
1106 --------
1107 format_float_positional
1108

Callers

nothing calls this directly

Calls 2

dragon4_scientificFunction · 0.90
_none_or_positive_argFunction · 0.85

Tested by

no test coverage detected