Learning the different kinds of rounding operations can have many applications. In this article I will explain what each rounding application in JavaScript does. Even though the code may change on different programming languages, they all do the same.
Examples:
Examples:
Examples:
Math.floor();
Rounds the number downExamples:
- Math.floor(1.5) = 1
- Math.floor(2.7) = 2
- Math.floor(1.3) = 1
Math.ceil();
Rounds the number upExamples:
- Math.ceil(1.5) = 2
- Math.ceil(2.7) = 3
- Math.ceil(1.3) = 2
Math.round();
Rounds the number to the closest integerExamples:
- Math.round(1.5) = 2
- Math.round(2.7) = 3
- Math.round(1.3) = 1
Comentarios
Publicar un comentario