Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

A Note about Floats

console.log(0.1 + 0.2);  // 0.30000000000000004
console.log((0.1 * 10 + 0.2 * 10) / 10);  // 0.3

console.log(1.03 + 1.04);  // 2.0700000000000003
console.log((1.03 * 100 + 1.04 * 100) / 100);  // 2.07
Source by learn.codeinstitute.net #
 
PREVIOUS NEXT
Tagged: #A #Note #Floats
ADD COMMENT
Topic
Name
4+9 =