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

  • Home
  • SEARCH
  • 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 5973861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:51:37+00:00 2026-05-22T20:51:37+00:00

I need to do integer division in JavaScript, which only gives me double-precision floating

  • 0

I need to do integer division in JavaScript, which only gives me double-precision floating point numbers to work with. Normally I would just do Math.floor(a / b) (or a / b | 0) and be done with it, but in this case I’m doing simulation executed in lockstep and need to ensure consistency across machines and runtimes regardless of whether they use 64-bit or 80-bit internal precision.

I haven’t noticed any inconsistencies so far, but I haven’t been able to conclusively convince myself that they can’t happen. So I’m left wondering:

  1. Assuming a and b are integers in range 0..2^31-1 and 1..2^31-1 respectively, are results from JavaScript Math.floor(a / b) (and a / b | 0) guaranteed to be consistent across machines and runtimes?

  2. Why or why not?

  • 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-05-22T20:51:38+00:00Added an answer on May 22, 2026 at 8:51 pm

    My guess would be no. And the answer would be that it’s dependent upon a number of factors:

    1. Browser vendor implementations of ECMA Script.

    2. Whether or not a particular version of ECMA Script specifies that level of consistency (typically not).

    3. Other, external factors on the end-users’ machines that you may not be aware of.

    Floating point arithmetic is notoriously susceptible to rounding errors. While it’s nice to think it’s accurate with all those digits to the right-hand side of the decimal point, getting two machines running vastly different hardware and software configurations to agree on a calculation can be like herding cats.

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

Sidebar

Related Questions

I need to do a floating-point division in a dos batch. I didn't find
I need some division algorithm which can handle big integers (128-bit). I've already asked
I need an algorithm that converts an arbitrarily sized unsigned integer (which is stored
I need to use Integer Linear Programming API/Tool for my application. Though my application
I need to compare the integer part of two doubles for inequality and I'm
I need to format an integer representation of bytes into something friendly, and I'm
I need to show an integer value in a TextBox in my C# Windows
I need to convert an integer to it's ASCII representation from within the Linux
I need to generate a random integer between 1 and n (where n is
I need to do some large integer math. Are there any classes or structs

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.