Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8840889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:34:24+00:00 2026-06-14T10:34:24+00:00

Possible Duplicate: Elegant workaround for JavaScript floating point number problem If I perform the

  • 0

Possible Duplicate:
Elegant workaround for JavaScript floating point number problem

If I perform the following operation in Javascript:

0.06120*400

The result is 24.48.

However, if I do this:

24.48/400

The result is:

0.061200000000000004

JSFiddle: http://jsfiddle.net/zcDH7/

So it appears that Javascript rounds things differently when doing division and multiplication?

Using my calculator, the operation 24.48/400 results in the correct answer of 0.0612.

How should I deal with Javascript’s inaccurate division? I can’t simply round the number off, because I will be dealing with numbers of varying precision.

Thanks for your advice.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:34:25+00:00Added an answer on June 14, 2026 at 10:34 am

    You can get the correct result with simply using:

    var a = 24.48/400;
    console.log(a.toFixed(6));
    

    And because typeof a.toFixed(6) === 'string' you can:

    var a = 24.48/400;
    console.log(parseFloat(a.toFixed(6)));
    
    • The argument of toFixed is the number of decimals you want.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Elegant workaround for JavaScript floating point number problem var sum = 0;
Possible Duplicate: Elegant workaround for JavaScript floating point number problem var sum = 0;
Possible Duplicate: Elegant workaround for JavaScript floating point number problem I would like to
Possible Duplicate: Elegant workaround for JavaScript floating point number problem Why is it that
Possible Duplicate: how to perform bitwise operation on floating point numbers Hello, everyone! Background:
Possible Duplicate: Number.sign() in javascript Given some number variable, what is the easiest way
Possible Duplicate: In R, what is the difference between these two? floating point issue
Possible Duplicate: How costly is .NET reflection? The elegant solution to a problem I
Possible Duplicate: && operator in Javascript In the sample code of the ExtJS web
Possible Duplicate: Can main function call itself in C++? I found this problem very

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.