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 8039117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:28:05+00:00 2026-06-05T03:28:05+00:00

Why is it that some numbers in scientific notation starting with 9.999999999999999 get rounded

  • 0

Why is it that some numbers in scientific notation starting with 9.999999999999999 get rounded to 1 while others remain the same?

For example, in Google Chrome 20 the following happens.

(9.999999999999999e+306).toString() === "9.999999999999999e+306" // true

but

(9.999999999999999e+303).toString() === "1e+304" // true

Why is that? Is it a floating point issue?

However the strangest thing is that in Opera 11.64 (1e23).toString() === "9.999999999999999e+22". I tried to report the 1e23 bug to Opera but no one replied.

Live Demo Here:
http://jsfiddle.net/3ekDK/3/

Source code of Demo

var console = console || {};
console.logToBody = function( str ){
    document.body.innerHTML += "" + str + "<br/>";
};      
var parts = ["9.999999999999999e", 310 ], tmp, tmp2;
while( parts[1]-- ){
    tmp = +(parts.join(''));
    if( /9.9{3,}e/.test( +tmp ) ){
        console.logToBody( tmp + " doesn't convert to " +  (+tmp).toPrecision(1) );
    }
    tmp2 = "1e"+parts[1];
    //Carakan Javascript Engine Math BUG:
    if( !/^1e*/.test( +tmp2 ) ){
        console.logToBody( tmp2 + " = " + (+tmp2) + " in the runtime environment.");
    }
}
  • 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-05T03:28:07+00:00Added an answer on June 5, 2026 at 3:28 am

    It’s because floating point numbers are sometimes an approximation. Some numbers can’t be represented by the floating point format, that is, a binary fraction, so they are approximated http://en.wikipedia.org/wiki/IEEE_754-2008

    That is why you should never rely on floating point arithmetic without rounding it. A simple example is the following:

    > 20.61 - .1
      20.509999999999998
    

    Here’s a great explanation of the floating point format http://www.randelshofer.ch/fhw/gri/float.html#chapterfloatingpointformat

    Ordinary Decimal 178.125

    Scientific Decimal 1.78125 E 102

    Scientific Binary 1.0110010001 E 2111

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some results file produced by Fortran programs report double precision numbers (in scientific notation)
suppose I have some numbers that form a series for example: 652,328,1,254 and I
I have some sql statements that calculates some numbers. It's possible (with bonus points/penalty
I've got some numbers that is now larger than INT can handle. This is
I have a list that has some chapter numbers in string. When I sort
I have a script that generates some numbers (specifically times in epoch form). Everytime
I have a custom report that shows some numbers in the form of a
I have a text string that contain some references numbers like [3][2][4] or [1]
I have an [] that has some numbers (distances from some point). I want
I'm making a game that displays some numbers on a canvas (score, time, etc).

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.