Math Functions
math.fsum()
Sum real inputs using a more accurate floating-point accumulation than naive addition; still returns a float.
Formal Syntax & Structure
python syntaxpython
math.fsum(iterable, /)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| iterable | iterable of real numbers | Values to accumulate. |
Return Value
float
Floating-point result; finite precision and domain restrictions apply.
Working Example
Example Snippetpython
import mathprint(math.fsum([1e16, 1, -1e16]))