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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:55:37+00:00 2026-06-12T23:55:37+00:00

This JavaScript demonstrates a bug in IE that is driving me nuts right now:

  • 0

This JavaScript demonstrates a bug in IE that is driving me nuts right now:

var y = 6044629098073143; // this exact integer easily fits into an IEEE double
document.write(y + " " + Math.round(y)+"<br><br>");

The output in IE 8 (and Opera 12.02) shows that Math.round is off by 1:

6044629098073143 6044629098073144

Output in Firefox, Chrome and Safari is correct.

What on earth is going on here with IE and Opera?

  • 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-12T23:55:38+00:00Added an answer on June 12, 2026 at 11:55 pm

    I’ve confirmed RobG’s comments: All integers below 2^52 (4503599627370496) appear to round correctly in all browsers. Integers higher than this round UP to an EVEN number in IE/Opera with Math.round (whereas other browsers round correctly).

    As RobG mentioned, it is likely that IE and Opera implement Math.round(x) as Math.floor(x + 0.5), which leads to these results since adding 0.5 to a value > 2^52 yields an imprecise result. A smarter implementation of round() would use the FPU’s native rounding support (IE and Opera developers, please take note and fix!)

    In the meantime, this workaround should work:

    // workaround for IE and Opera's brain-dead Math.round() implementation
    if (y < 4503599627370496) // 2^52
    {
      y = Math.round(y);
    }
    // else 'y' is already an integer
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this Javascript function that sends username and password to php file through
I'm looking for a barebones javascript example that demonstrates how the javascript plugin architecture
I have this fragment that demonstrates the problem: <html> <head> <title>height query demo</title> <script
i have JavaScript components, that has following architecture: var MyComponent = function(params) { setup(params);
This isn't a javascript question but I've created a fiddle so I can demonstrate
This Javascript code is using the 'this' keyword inside a nested function (which is
This javascript function takes JSON and formats it to XML. The data is a
This javascript code does not work in IE8, but works in Firefox and Google
This javascript will find all my selects and validate them but I want to
Given this JavaScript code (which is just a comment referring to a url): //

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.