This JavaScript tutorial explains how to use the math feature called fround() with syntax and examples.
Description
In JavaScript, fround() is a function that is used to spherical a quantity to a 32-bit single precision flow value. Because the fround() characteristic is a static function of the Math object, it ought to be invoked through the placeholder object known as Math.
Syntax
In JavaScript, the syntax for the fround() characteristic is:
Math.fround(number);
Parameters or Arguments
number The number which will be rounded to a 32-bit single precision go with the flow number.
Returns
The fround() characteristic returns the variety rounded to a 32-bit single precision float value.
Note
Math is a placeholder object that consists of mathematical features and constants of which fround() is one of these functions.
Example
Let’s take a seem at an instance of how to use the fround() function in JavaScript.
For example:
console.log(Math.fround(32));
console.log(Math.fround(8.1));
console.log(Math.fround(-4.2));
In this example, we have invoked the fround() function the use of the Math class.
We have written the output of the fround() feature to the net browser console log, for demonstration purposes, to exhibit what the fround() function returns.
The following will be output to the web browser console log:
32
8.100000381469727
-4.199999809265137
In this example, the first output to the console log lower back 32 which is the rounded 32-bit single precision glide representation of 32.
The 2d output to the console log again 8.100000381469727 which is the rounded 32-bit single precision float representation of 8.1.
The 1/3 output to the console log returned -4.199999809265137 which is the rounded 32-bit single precision flow illustration of -4.2.
Leave a Review