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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:44:17+00:00 2026-05-26T00:44:17+00:00

I have used the function atoi to convert character strings to int and it’s

  • 0

I have used the function atoi to convert character strings to int and it’s working fine but when I gave

num = atoi (argv[1]) ;

// argv contain 4294967295 maximun value of 32 bit integer

it’s giving me 2147483647 answer which is basically half of 4294967295

i guess that its because of difference of bytes in char and int.
Can any one explain whats happening to bits and bytes
and how to fix it or convert it to 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-05-26T00:44:17+00:00Added an answer on May 26, 2026 at 12:44 am

    You’ve run into the maximum value of an integer. Since atoi returns an int, it is limited to the size of an integer on your machine. It looks like your machine uses 32-bit ints.

    In case you missed it (it’s easy to miss), 2147483647 = (2 ^ 31) – 1. Remember that ints can be negative, and the leftmost bit is the sign bit in that case. That’s why you see the number being “limited” to 2147483647.

    Try defining num as unsigned int instead of int, and use strtoul instead of atoi.

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

Sidebar

Related Questions

I have used a regex function on a textbox, but it's not working. <input
Update 2 : So I never have used the debug function in firebug, but
I have used many of the Convert.To..... functions for conversion , but I didn't
I have used a scrollTop function in jQuery for navigating to top, but strangely
I have used class_replaceMethod function and it works good with instance methods, but I
I've used the contains() function successfully, but never have used it with an if-statement
I'm working on win 32 multithreading with c++. Scenario: I have a function used
I have used onclick function. after click a button show data. but intially data
I have used sendinput() function and windows keyboard hooks to develop a custom keyboard
I have used the crypt function in c to encrypt the given string. I

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.