This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: Code Composer Studio
Hi,
I use strtol function to convert "0xFFFFFFFF" to a uint32_t data. However, I got an error due to result out of range. Tracing into the function, I noticed that the maximum result was set to 0x07FFFFFF. Please see the attached picture.I tried to change the LONG_MAX definition, but could not find it.
Is there a reason to set the maximum value to be 0x07FFFFFF? How to fix this to covert value higher than 0x07FFFFFFF?
thanks
Peng
Peng Peng said:Is there a reason to set the maximum value to be 0x07FFFFFF?
Yes. That is the maximum signed value you can represent in 32-bits. Remember, if the most significant bit is set, then it is a negative value.
If you need to work with positive values higher than 0x7FFFFFFF, then you must use a different type. Consider using unsigned long or long long. And don't forget to change from strol to strtoul or strtoll.
Thanks and regards,
-George
George,
Thanks for the reminder. I guess I was confused by the 0x07FFFFFFF. Checked the code again, that was the value before the last number. So it makes sense now.
Peng