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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:51:57+00:00 2026-06-12T21:51:57+00:00

I use the library bitarray to manage my bits conversion and to write a

  • 0

I use the library bitarray to manage my bits conversion and to write a binary file in Python. The bitarray.to01() before writing to file is of length 4807100171. For some reason I can’t make sense of, after getting the bits fromfile (b.fromfile(file)) and then converted to a string of 0s and 1s with to01(), there is not only 0s and 1s in my string (\x00) and then, when I work with it, I get this error:

ValueError: invalid literal for int() with base 2: '0000000000000000\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

I wonder if there could be a size limit for the string coming from a file or some issues as such. If so, I haven’t found anything about it…

Edit:

Here’s a way to reproduce the problem:

import re
from bitarray import bitarray 

b = bitarray(4807100171)
b.setall(False) 

if re.match("^[\d]+$", b.to01()):
    print "there is only digits in this string."
else:
    print "there is not only digits in this string."

** Edit #2:

However, if I check my machine using platform.architecture() and sys.maxint, I get this:

In [1]: import platform, sys
In [5]: platform.architecture(), sys.maxint
Out[5]: (('64bit', ''), 9223372036854775807)

So, this is approximately 2^63. How come it truncates at 2^32?
I have 4GB of ram. I get that 2^32*1.16415e-10*8 (since I’m converting it to a string) ~= 4GB… But what about the fact that this is a 64bit machine?

  • 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-12T21:51:59+00:00Added an answer on June 12, 2026 at 9:51 pm

    ould not have memory on your machine to run the to01 method on a bitarray that size. The string will use one byte per digit (at least) – and you hae more than 2**32 digits. Since you are not swappign or getting out of memory errors, you may have hit some bug in bitarray —
    But…step back!

    Why on Earth woul you like a 4 billion digit string of “0” and “1”s? Print your self a Matrix themed racing track??

    If you need to convert even a few hundred thousand digits to 0s and 1s , to look for some pattern, or whatever, you better doing it interactively, converting a few bytes at a time than wathever you are trying there.

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

Sidebar

Related Questions

I am trying to use FileHelper library for parsing a text file. Ultimately the
I use SharpSvn library from CollabNET. I would like to set revision author while
We use Enterprise Library 3.0 to access Oracle DB (microsoft oracle client). What happens
I use this library: https://github.com/robbiehanson/CocoaAsyncSocket My test code: #import <UIKit/UIKit.h> @class GCDAsyncUdpSocket; @interface ThirdViewController
I try to use gson library to deserialize a flow of objects sent to
How can I use Enterprise Library to do a Data Access Layer in c#
When should you use a library or a framework vs your own implementation. For
im going to use Sociallib library in my app to interact with social networks.
Is it possible to use a library compiled by visual studio in an application
I'm trying to use this library (which looks very nice) but I'm having difficulty

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.