Math.fround
Returns the nearest 32-bit single precision float representation of a number
Syntax
Math.fround(doubleFloat)Parameters
| Parameter | Type | Description |
|---|---|---|
| doubleFloat | number | A number |
Return Value
The nearest 32-bit single precision float
Examples
console.log(Math.fround(5.5)); // 5.5
console.log(Math.fround(5.05)); // 5.050000190734863console.log(Math.fround(1.337)); // 1.3370000123977661
console.log(Math.fround(NaN)); // NaNconst precise = 0.1 + 0.2;
const f32 = Math.fround(precise);
console.log(precise); // 0.30000000000000004
console.log(f32); // 0.30000001192092896Understanding Math.fround
The Math.fround method in JavaScript returns the nearest 32-bit single precision float representation of a number. It belongs to the Math object and is one of the most widely used methods for working with math values in modern JavaScript and TypeScript applications.
The method signature is Math.fround(doubleFloat). It accepts 1 parameter: doubleFloat. When called, it returns the nearest 32-bit single precision float. Understanding when and how to use fround() helps you write more expressive, readable code.
Common use cases for Math.fround include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like math-clz32, math-imul, number-tofixed, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for Math.fround is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.
Browser Compatibility
Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.
Related Methods
More Math Methods
Other methods in the Math object
Related Tools
More Math Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.