0

Hi, to all, I'm having the following problem:
I'm trying to convert a CString to long(or number), but the number that is in the Cstring is too big and I loose data of the number.
I was thinking in using instead of long use the variable ULONGLONG, but the problem is that I don't know if there is Build-in method that converts Cstring to ULONGLONG.
Any ideas, how I can solve this problem, convert a big number stored in a CString and save it in a variable number.
I try this but is not working

CString pi_sString = ''1099511627775";
long nNumber = atol(pi_sString);

Thanks :rolleyes:

4
Contributors
4
Replies
5
Views
11 Years
Discussion Span
Last Post by dev.cplusplus
0

long integers also have a maximum value. They are made up of 4 bytes (32bits) (depending on each pc) and can only hold upto a certain number. If you try to go past this number you will wrap around and start at the beginning. Try using unsigned long int, which will double the maximum value the long integer can handle

0

long integers also have a maximum value.

True, it's 4294967296 to be exact. So that won't work for you, I suggest you go with Ancient Dragon's solution and use 64 bits.

Regard Niek

0

Thanks for the quick reponses,
I found a solution, store the value in a ULONGLONG variable and use the "_atoi64" method

ULONGLONG nBigNumber = _atoi64(pi_sString);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.