0
public class Test {

public static void main(String[] args) {
    double BASE = 0.4527210187492833;
    double num = 0.4527210187492833;

    for (int i = 0; i < 1000000000; i++) {
        num+=2.7755575615628914E-17;
    }

    System.out.println(num);
    System.out.println(BASE == num);
}

}

prints 0.4527210187492833 true

Shouldn't this print 0.4527210187492833 + (1000000000 * 2.7755575615628914E-17) ≈ 0.4527210465 -> false?

dts
  • 1

0 Answers0