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

NameTypeDescription
iterableiterable of real numbersValues 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]))
Python Reference