Created
June 10, 2020 00:19
-
-
Save cosinekitty/fbbd02e4cd8337a3de0253932aafd3d1 to your computer and use it in GitHub Desktop.
The NaN trap illustrated
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
function UnitTest() { | |
const polar = Polar(3.0, 4.0); | |
const expected_distance = 5.0; | |
const diff = polar.distance - expected_distance; | |
if (Math.abs(diff) > 1.0e-12) { | |
console.error('ERROR: Excessive distance error: ', diff); | |
return 1; | |
} | |
console.log('PASS'); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment