Using string() on double values without automatic rounding?
10 ビュー (過去 30 日間)
古いコメントを表示
Hello,
When i use string() with double values, the number is converted to a string where the number is rounded to four decimals, even when there are more decimals in the original double value. Image:

I am currently writing a conversion script where i need the extra decimals. Is it possible to disable this automatic rounding?
Thank you.
0 件のコメント
採用された回答
その他の回答 (1 件)
Stephen23
2023 年 5 月 9 日
Rather than slow NUM2STR and then STRING, for a scalar the simpler and more efficient approach is to just call SPRINTF:
sprintf("%.9f",123.123123123)
For non-scalar values use COMPOSE:
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!
