Created
October 1, 2014 17:29
-
-
Save ericsoco/0f95c01bdb5c87fad287 to your computer and use it in GitHub Desktop.
wtfjs: negative mod, equality
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check if a thing is rotated 90°. | |
function isRotatedOffAxis (rotation) { | |
return rotation % 180 !== 0; | |
} | |
// Hm, what about -180? | |
console.log(-180 % 180); // -0. wtf #a | |
// So then why is this ok? | |
isRotated(-180); // false | |
// Because: | |
console.log(0 === -0); // true. wtf #b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment