Jump to content
  • Advertisement
Sign in to follow this  
EvilNando

Why is this happening????

This topic is 4145 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have this: pTicketId->TicketNum = (DWORD) atol (_aux_str); where: _aux_str = char [17] with a value of "3964856790" so .. when doing this typecast , I expect to get a number == 3964856790 for pTicketId->TicketNum but instead i keep getting 2147483647!!!!! why is this happening .. does have something to do with my IDE? (im using vs2005 pro) thanks a lot guys

Share this post


Link to post
Share on other sites
Advertisement
From the MSDN:
Quote:
In Visual C++ 2005, in the case of overflow with large positive integral values, atol returns LONG_MAX; in the case of overflow with large negative integral values, LONG_MIN is returned. In all out-of-range cases, errno is set to ERANGE.


You have an overflow, and you're getting LONG_MAX returned. Because 3964856790 can't be represented in a 32-bit signed integer.

Share this post


Link to post
Share on other sites
2147483647 is the DWORD-equivalent of -1. So, atol is trying to tell you that it encountered an error while trying to convert your value.
I think Steve is right, you can store max. 2,147,483,657.

You might also consider to use strtol, which is a bit better in reporting errors.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!