double frick!

Copy and paste the following code into the address bar of your browser, and press enter:

javascript:if (.2 + .4 == .6) alert("frick!"); else alert("double frick!");

The code basically says, “If .2 + .4 is equal to .6, then pop up a window with the message, ‘frick!,’ otherwise, pop up a window with the message, ‘double frick!’” I didn’t learn this until yesterday, but the problem is that floating-point data types don’t always store exact values, but approximations of them, so the “wrong” pop up appears.

0 Responses to “double frick!”


  1. No Comments

Leave a Reply

You must login to post a comment.