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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:17:20+00:00 2026-06-01T13:17:20+00:00

For example, how to get the correct answer to 137438953472 & 137438953472 ? Javascript

  • 0

For example, how to get the correct answer to 137438953472 & 137438953472?

Javascript returns 0 if operands are between 2^32 and 2^53(max int).

  • 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-01T13:17:21+00:00Added an answer on June 1, 2026 at 1:17 pm

    Ok here’s what I came up with, only tested with unsigned integers < 2^53:

    edit: nailed a bug when partial results are interpreted as signed

    function and( op1, op2 ) {
    
        var mod = Math.pow( 2, 32 ),
            op1mod = op1 % mod,
            op2mod = op2 % mod,
            op164to32,
            op264to32,
            res32, res64, res;
    
            op1 -= op1mod;
            op2 -= op2mod;
    
            res32 = ( op1mod & op2mod ) >>> 0;
    
    
            op164to32 = op1 / mod;
            op264to32 = op2 / mod;
            res64 = ( op164to32 & op264to32 ) >>> 0;
    
            res = res64 * mod + res32;
            return res;
    }
    
    and( 137438953473, 137438953473 )
    //137438953473
    and( 137439087606, 137438953473)
    //137438953472
    and( 0xCAFECAFECAFE, 0xBABEBABEBABE )
    //152550976162494
    

    results confirmed to be correct with windows 64 bit calculator 😛

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

Sidebar

Related Questions

Does clojure have a powerful 'loop' like common lisp. for example: get two elements
For example to get the favicon of a site I can use http://www.google.com/s2/favicons?domain= and
Here is an example to get different parts of a filename bash-3.2$ pathandfile=/tmp/ff.txt bash-3.2$
I am following this example to get JSONP data from remote server. jQuery append
How to converted string with space in double quoted string. For Example: I get
I'm having troubles setting the background color for JButtons. For example I get this
Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx However, I can't seem to get
First of all there is probably no correct answer, but I'm sure there are
Not sure if there is a correct answer to this, so I've flagged it
I've searched Google all day and can't find the correct answer to my issue,

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.