Why does str2num truncate my number so early?
14 次查看(过去 30 天)
显示 更早的评论
When I try to convert from string to number, I lose precision?
whos test_str
Name Size Bytes Class Attributes
test_str 1x9 18 char
K>> test_str
test_str =
0.067354
K>> str2num(test_str)
ans =
0.0674
0 个评论
采纳的回答
更多回答(1 个)
Sara
2014-6-23
Use
sprintf
so you can control the precision you want.
3 个评论
Jairo Andrés Gutiérrez Suárez
2022-2-7
Yep but that method is not efficient. There should be a way to use the exact number of decimals. What if I am using srt2num to find a folder with the same number I looked for?
另请参阅
类别
在 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!