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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:41:29+00:00 2026-06-14T20:41:29+00:00

32-bit binary string conversion from string to integer fails. See below strtoi(10101101100110001110011001111111, base=2) #

  • 0

32-bit binary string conversion from string to integer fails. See below

strtoi("10101101100110001110011001111111", base=2)
# [1] NA

Any ideas what the problem might be ?

  • 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-14T20:41:30+00:00Added an answer on June 14, 2026 at 8:41 pm

    It looks like strtoi cannot handle numbers greater than 2^31:

    strtoi("1111111111111111111111111111111", base=2L)
    # [1] 2147483647
    strtoi("10000000000000000000000000000000", base=2L)
    # [1] NA
    

    which is the maximum integer my machine (and probably yours) can handle for an integer:

    .Machine$integer.max
    # [1] 2147483647
    

    Note that the documentation does warn about overflow (from ?strtoi):

    Values which cannot be interpreted as integers or would overflow are returned as NA_integer_.

    What you can do is write your own function that returns the output as a numeric instead of an integer:

    convert <- function(x) {
        y <- as.numeric(strsplit(x, "")[[1]])
        sum(y * 2^rev((seq_along(y)-1)))
    }
    
    convert("1111111111111111111111111111111")
    # [1] 2147483647
    convert("10000000000000000000000000000000")
    # [1] 2147483648
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to convert 64 bit binary string to 64 bit integer (unsigned). Is
Is there any solution to find a specific binary bit value inside a string
I have a 56 bit binary string that i want to use as the
If I have a 5 bit binary string such as '01010' , how can
I have problem with getting value from binary registry key. My code so far
I'm trying to write a small bit of binary data as a string to
Using Mathematica Binary String: FBCD #1 I: ImportString[FBCD, {Binary, Bit}] O: {0, 1, 0,
I have a IEEE754 Double precision 64-bit binary string representation of a double number.
If I have a 32-bit binary number and I want to replace the lower
The solution in How to compile a 32-bit binary on a 64-bit linux machine

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.