Skip to content

Value checker: rounding from double to float #6141

@mernst

Description

@mernst

Run javacheck -processor value on this code:

public class DoubleRounding {

  final double FLOATING_POINT_DELTA = 1e-15;

  void round() {
    float f = (float) FLOATING_POINT_DELTA;
  }
}

The result is:

DoubleRounding.java:6: warning: [cast.unsafe] cast from "@DoubleVal(1.0E-15) double" to "@DoubleVal(1.0000000036274937E-15) float" cannot be statically verified
    float f = (float) FLOATING_POINT_DELTA;
              ^
1 warning

The test case is checked in.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions