Having problem converting a string to an integer using sscanf
조회 수: 7 (최근 30일)
이전 댓글 표시
Hi all, I'm having an issue converting a string to a number. See a copy of my problem below:
>> b = sscanf('123456789012345678', '%lu')
b =
4.2950e+009
Why is this happening? The same problem occurs all the way down to 10 digits. At 9, it returns the integer as expected. Your help is appreciated.
댓글 수: 7
Guillaume
2020년 1월 28일
Yes, you could actually store the number if sscanf didn't convert to double. However since 123456789012345678 is greater than flintmax you'd be losing precision anyway (the number will get rounded down to 123456789012345680)
In any case, it does look like sscanf is limited to 32-bit numbers in your case.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!