Skip to content

Add Math.sumPrecise support #1778

@anivar

Description

@anivar

Hermes lacks Math.sumPrecise, a TC39 Stage 3 proposal for high-precision floating-point summation.

Problem:

[1e20, 1, -1e20].reduce((a, b) => a + b, 0)  // Returns 0, loses precision
Math.sumPrecise([1e20, 1, -1e20])            // Would return 1

Use cases:

  • Financial calculations in React Native apps
  • Scientific computing requiring numerical stability
  • Data aggregation without accumulated rounding errors

Specification: https://github.com/tc39/proposal-math-sum (Stage 3)

Implementation ready: I have a working implementation using Shewchuk's algorithm. Should I proceed with a PR?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions