modifying/​rounding/a​proximatin​g a number

5 vues (au cours des 30 derniers jours)
Opariuc Andrei
Opariuc Andrei le 30 Oct 2020
Commenté : Star Strider le 31 Oct 2020
i need a way to modify a number a=2.65987 into 2.6598 i tried round /fprintf , but both display as 2.6599 ,i need it badly ,i could just pop it out of nowhere by substracting 0.00007 but that's not helping .

Réponse acceptée

Star Strider
Star Strider le 30 Oct 2020
One option:
c = floor(a*1E4)/1E4
producing:
c =
2.6598
.
  6 commentaires
Opariuc Andrei
Opariuc Andrei le 31 Oct 2020
i checked , she doesn't know , i gave her something to ponder about :) / homework
Star Strider
Star Strider le 31 Oct 2020
Interesting!
Check the link I posted — the link information is correct.
While I would normally suggest that the difference between the two in the precision of the diaplayed numbers could account for the difference, that is not the situation here, where the display precision is not changing.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by