January 11 2019, 02:05

Excellent little problem for an interview. Answer the question “why”

Mac OS calc shows 1e-27, while Google’s calculator shows zero, and in java System.out.println((4195835/3145727)*3145727-4195835) outputs “-1050108”, but after a simple change, it outputs the correct zero.

And another for bedtime. How much will Python output in response to “print(0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1)”? And Java? System.out.println(0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1);

Leave a comment