Effacer les filtres
Effacer les filtres

Problems with decimal places?

2 vues (au cours des 30 derniers jours)
Trevor Zane Simko
Trevor Zane Simko le 6 Mai 2015
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.

Réponse acceptée

Walter Roberson
Walter Roberson le 6 Mai 2015
%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 commentaire
Trevor Zane Simko
Trevor Zane Simko le 6 Mai 2015
I see. Thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by