# How to format a float in JavaScript ?

Format a float number means to round off a number up to the given decimal place, ceiling, flooring, etc. There are many operations used to format the float number which are given below: Math.ceil(), float.toFixed() and Math.round() Method: All the methods are similar and giving the same output. The implementation of Math.ceil() and Math.round() are totally same but the Math.round() function is used to round a number to its nearest integer. Example:
 ` `` `` ` ` ``    `` ``        ``How to format a float ``        ``value ``in` `javascript ? ``    `` `` `` ` ` ``    ``

``        ``GeeksforGeeks ``    ``

``     ` `    ``

``        ``Format a float value ``        ``6.56759 ``in` `JavaScript ``    ``

``     ` `    ``

``    ``

``    ``

``    ``

``    ``

`` ` `    `` `` `` ` ` `

Output: Math.floor() Method: The Math.floor() function is used to round off the number passed as a parameter to its nearest integer in Downward direction of rounding i.e. towards the lesser value. Example:
 ` `` `` ` ` ``    `` ``        ``How to format a float ``        ``value ``in` `javascript ? ``    `` `` `` ` ` ``    ``

``        ``GeeksforGeeks ``    ``

``     ` `    ``

``        ``Format a float value ``        ``6.56759 ``in` `JavaScript ``    ``

``     ` `    ``

``    ``

``    ``

`` ` `    `` `` `` ` ` `

Output: float.toExponential() Method: The toExponential() method is used to convert a number to its exponential form. It returns a string representing the Number object in exponential notation. Example:
 ` `` `` ` ` ``    `` ``        ``How to format a float ``        ``value ``in` `javascript ? ``    `` `` `` ` ` ``    ``

``        ``GeeksforGeeks ``    ``

``     ` `    ``

``        ``Format a float number ``        ``in` `JavaScript ``    ``

`` ` `    ``

`` ` `    `` `` `` ` ` `

Output: number.toPrecision() Method: The toPrecision() method is used to format a number to a specific precision or length. If the formatted number requires more number of digits than the original number then decimals and nulls are also added to create the specified length. Example:
 ` `` `` ` ` ``    `` ``        ``How to format a float ``        ``value ``in` `javascript ? ``    `` `` `` ` ` ``    ``

``        ``GeeksforGeeks ``    ``

``     ` `    ``

``        ``Format a float number ``        ``in` `JavaScript ``    ``

`` ` `    ``

``    ``

``    ``

``     ` `    `` `` `` ` ` `

Output:

Previous
Next