Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
why does adding sometimes result in micro differences?

For some reason, when looping through and adding 0.01 to a variable, it will sometimes result in adding 0.01999999999999999 instead of just 0.01. Here is the a screenshot with the console output: console log And here is the code:

var num1 = 0.00;
var num2 = 0.00;

var maxNum = 5.55;

while(num1 <= maxNum){
    console.log('outer num1: ' + num1);
    console.log('outer num2: ' + num2);
    console.log('');  
    while(num2 <= maxNum){
        console.log('inner num1: ' + num1);
        console.log('inner num2: ' + num2);
        console.log(''); 
        num2 = num2 + 0.01;
    }
    num1 = num1 + 0.01;
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!