Math
is a built-in object in JavaScript that contains different methods and properties used to perform mathematical operations.
We use the Math.fround()
function to compute to the nearest 32-bit single-precision floating-point number.
Math.fround(param);
param
: This is the input value of the Number
type for which we want to find the fround()
.
Number
in JavaScript is a 64-bit double-precision value that is the same asdouble
in C# or Java.
Number
: The Math.fround()
function returns the next nearest 32-bit floating point of the input parameter param
. It is of the Number
type.
NaN
: The Math.fround()
function returns param
is not of the Number
type.
console.log("fround(-1.23) = " + Math.fround(-1.23));console.log("fround(0.54) = " + Math.fround(0.54));console.log("fround(1.23) = " + Math.fround(1.23));console.log("fround('1.23') = " + Math.fround('1.23'));console.log("fround('educative') = " + Math.fround('educative'));