Effacer les filtres
Effacer les filtres

how to round 10.5 to 10 ?

3 vues (au cours des 30 derniers jours)
tomer polsky
tomer polsky le 3 Juil 2018
hello I want to round down from 10.5 to 10 is there a command for this operation ?
  1 commentaire
Walter Roberson
Walter Roberson le 3 Juil 2018
Is the question about the rounding of values that end in 0.5 exactly, since round() typically rounds those up?

Connectez-vous pour commenter.

Réponses (2)

Stephen23
Stephen23 le 3 Juil 2018
  1 commentaire
Stephen23
Stephen23 le 3 Juil 2018
tomer polsky's "Answer" moved here:
thank you

Connectez-vous pour commenter.


Asit Kumar
Asit Kumar le 4 Juil 2018
both fix and floor will give the same answer for positive decimal numbers (if your intention is to round down regardless the decimal value)
But they will produce different results for negative decimals:
1. fix
fix rounds towards 0
fix(10.5) = 10
fix(-10.5) = -10
2. floor
floor rounds towards negative infinity
floor(10.5) = 10
floor(-10.5) = -11

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by