Skip to content

bug in IRootFunctions double.Hypot #75651

Description

@c-ohle

Description

The double.Hypot function returns negative results.

public static double Hypot(double x, double y)
It is in the line result = x + y; where the abs values should be used.

Just as note: I've found that the algorithm used is less precise and slower than a common implementation.

Reproduction Steps

  x = double.Hypot(1, +1e20); // 1E+20 ok
  x = double.Hypot(1, -1e10); // 1E+10 ok
  x = double.Hypot(1, -1e20); // -1E+20 wrong

Expected behavior

  x = double.Hypot(1, +1e20); // 1E+20 ok
  x = double.Hypot(1, -1e10); // 1E+10 ok
  x = double.Hypot(1, -1e20); // 1E+20 

Actual behavior

  x = double.Hypot(1, +1e20); // 1E+20 ok
  x = double.Hypot(1, -1e10); // 1E+10 ok
  x = double.Hypot(1, -1e20); // -1E+20 wrong

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions