フィルターのクリア

Problems with decimal places?

2 ビュー (過去 30 日間)
Trevor Zane Simko
Trevor Zane Simko 2015 年 5 月 6 日
コメント済み: Trevor Zane Simko 2015 年 5 月 6 日
I'm writing a script that prints a certain percentage to the screen:
fprintf('Probabilty of something happeneing: %d %% \n \n',Percentage_A);
When Percentage_A (which is calculated earlier in the script) has a decimal place, such as: 92.3077, it show's up as 9.230769e+01. How do I fix this? Thank you.

採用された回答

Walter Roberson
Walter Roberson 2015 年 5 月 6 日
%d is only for integral numbers. If you want to print out floating point numbers without any decimal places then you can use %.0f . Or you can round() the numbers and continue to use %d
  1 件のコメント
Trevor Zane Simko
Trevor Zane Simko 2015 年 5 月 6 日
I see. Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by