“Math.Round” Respostas de código

Como exibir Inteiger para um décimo em JavaScript

Math.round(3.14159 * 100) / 100  // 3.14

3.14159.toFixed(2);              // 3.14 returns a string
parseFloat(3.14159.toFixed(2));  // 3.14 returns a number

Math.round(3.14159)  // 3
Math.round(3.5)      // 4
Math.floor(3.8)      // 3
Math.ceil(3.2)       // 4
Bright Beaver

JS arredondando

//There are meny ways of rounding...
Math.floor(5.5) //Answer 5, it alwas rounds down.
Math.round(5.5) //Answer 6, it simpily rounds to the closest whole number.
Math.ceil(5.5) //Answer 6, it alwas rounds up.

//You can do more things too...
Math.floor(5.57 * 10) / 10 //Answer 5.5, the number turns into 55.7, Then gets floored (55.0), Then gets divied, (5.5).
Determined Programmer

C# Número redondo

double number = 1.5362
  
int rounded = Math.Round(number)
//rounds number to 2
  
double rounded_2 = Math.Round(number, 2)
//rounds number to 1.54
Plain Penguin

arredondando em javascript

var avg=10.55;
console.log(Math.round(avg)); //Prints 11
Gorgeous Gerenuk

Math.Round

console.log(Math.round(5.95)); // output: 6

console.log(Math.round(5.23)); // output: 5

console.log(Math.round(-15.5)); // output: -15
Brainy Butterfly

Math.Round

import java.lang.*;

public class MathDemo {

   public static void main(String[] args) {
   
   //what is Math.round(3.45)

      double x = 3.45;

      System.out.println("Math.round(" + x + ")=" + Math.round(x));
   }
}

//the Output is 3
Xenophobic Xenomorph

Respostas semelhantes a “Math.Round”

Procure respostas de código populares por idioma

Procurar outros idiomas de código