Skip to content

Float64x2.min() and max() do not handle NaN properly. #31048

Closed

Description

@alexmarkov
import 'dart:math';
import 'dart:typed_data';

test_min(double x, double y) {
  print("          min($x, $y) = ${min(x, y)}");
  print("Float64x2.min($x, $y) = ${new Float64x2(x, 0.0).min(new Float64x2(y, 0.0)).x}");
}

test_max(double x, double y) {
  print("          max($x, $y) = ${max(x, y)}");
  print("Float64x2.max($x, $y) = ${new Float64x2(x, 0.0).max(new Float64x2(y, 0.0)).x}");
}

main() {
  test_min(1.0, double.NAN);
  test_min(double.NAN, 1.0);

  test_max(1.0, double.NAN);
  test_max(double.NAN, 1.0);
}
          min(1.0, NaN) = NaN
Float64x2.min(1.0, NaN) = NaN
          min(NaN, 1.0) = NaN
Float64x2.min(NaN, 1.0) = 1.0
          max(1.0, NaN) = NaN
Float64x2.max(1.0, NaN) = NaN
          max(NaN, 1.0) = NaN
Float64x2.max(NaN, 1.0) = 1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.library-typed-datatype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions