Skip to content

Instantly share code, notes, and snippets.

@cosinekitty
Created June 10, 2020 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cosinekitty/fbbd02e4cd8337a3de0253932aafd3d1 to your computer and use it in GitHub Desktop.
Save cosinekitty/fbbd02e4cd8337a3de0253932aafd3d1 to your computer and use it in GitHub Desktop.
The NaN trap illustrated
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