How to round a float to integer (upwards)?

1

I have an operation that returns a float for example 6.3 and I need to round it to 7 I have tried with Math.round(6.3) but when the decimal is less than 0.5 it rounds down and when it is bigger it rounds up and I need it to always do it upwards.

    
asked by Pavlo B. 14.06.2018 в 10:34
source

1 answer

2

To round up, use Math.ceil :

let numero= 6.345;


let entero = Math.ceil(numero);

console.log(entero)

Source

    
answered by 14.06.2018 / 10:36
source