Skip to content

Instantly share code, notes, and snippets.

View MinaidisKostas's full-sized avatar

Minaidis Kostas MinaidisKostas

View GitHub Profile
@MinaidisKostas
MinaidisKostas / float_bug.js
Created May 13, 2024 23:25 — forked from lsloan/float_bug.js
JavaScript floating point math bug example
/*
* Demonstrate JavaScript floating point math bugs by showing
* which two-decimal-place numbers between 0.00 and 1.00 inclusive
* have fractional parts after being multiplied by one hundred.
*/
var i = 0.00;
for (n = 0; n <= 100; ++n) {
j = i * 100;
if (Math.round(j) != j) {