Is there a way to avoid this inaccuracy when converting an string to a double and then to an unsigned int? I have tried using str2num() but get the same result.Thanks!
3 次查看(过去 30 天)
显示 更早的评论
uint64(str2double('132697151393876469'))
%ans =
% uint64
% 132697151393876464
% note that the ans is the same for inputs 1326971513938764XX, where XX is in the range (57-71)
0 个评论
采纳的回答
更多回答(1 个)
the cyclist
2021-9-28
The reason for this is that MATLAB uses double-precision arithmetic by default, which will typically give approximately 15 decimal digits of precision.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!