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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:39:31+00:00 2026-05-28T00:39:31+00:00

I have a 64 element JavaScript array that I’m using as a bitmask. Unfortunately,

  • 0

I have a 64 element JavaScript array that I’m using as a bitmask. Unfortunately, I’ve run into a problem when converting from a string to binary, and back. This has worked for some other arrays, but what is going on here?

var a = [1, 1, 1, 1, 1, 1, 1, 1,
         1, 1, 1, 1, 1, 1, 1, 1,
         1, 1, 0, 0, 1, 1, 1, 1,
         1, 1, 0, 0, 1, 1, 1, 1,
         1, 1, 0, 0, 0, 0, 1, 1,
         1, 1, 0, 0, 0, 0, 1, 1,
         1, 1, 1, 1, 1, 1, 1, 1,
         1, 1, 1, 1, 1, 1, 1, 1];

var str1 = a.join('');
  //-> '1111111111111111110011111100111111000011110000111111111111111111'

var str2 = parseInt(str1, 2).toString(2);
  //-> '1111111111111111110011111100111111000011110001000000000000000000'

str1 === str2  //-> false

I would expect str2 to be the same as str1, which is not the case.

  • 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-28T00:39:31+00:00Added an answer on May 28, 2026 at 12:39 am

    In JavaScript, the Number type is a 64-bit double-precision value (more, and more). You’ve specified 64 bits there, which is beyond the realm that a 64-bit double-precision value can specify accurately (as it’s a floating point type, and so must devote some bits to precision). JavaScript doesn’t have an integer type (much less a 64-bit version of one), which is what a perfect-fidelity conversion would require.

    I’m not all that up on floating point bit representations, but IIRC a 64-bit double-precision number can accurately represent integer values on the order of 53 significant bits, see the links for details.

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

Sidebar

Related Questions

I have a form element that I want to address via javascript, but it
I want to have HttpModule to inject javascripts, css links into HEAD element from
I have an array that contains 10 elements, each element contains . How do
I have a C# ASP.NET app that creates a JavaScript array of values for
To check if an element is an array in JavaScript, I have always used
I am using jQuery and PHP. I have a JavaScript array , when I
My problem: I have an JSON Array containing arrays, which i render into the
Using javascript, how can I add to an array an element which contains fields
I'm creating my own JavaScript Array-like object and I have methods that call closures.
In my Javascript code, I have a string that is something like this: 1943[15]43[67]12[32]

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.