# Revision 463583 of Math.fround

• Revision slug: JavaScript/Reference/Global_Objects/Math/fround
• Revision title: fround
• Revision id: 463583
• Created:
• Creator: bbouvier
• Is current revision? No
• Comment

## Summary

This operation returns the nearest simple-precision float representation of its single parameter.

Method of `Math`
Implemented in JavaScript 1.8.5+
ECMAScript Edition ECMAScript 6th Edition

## Syntax

``Math.fround(x)``

`x`
Any number.

## Description

`Math.fround` returns the closest single-precision float value of its unique argument. See also Wikipedia's page on Single Precision.

## Examples

```Math.fround(0) // 0
Math.fround(1) // 1
Math.fround(1.337) // 1.3370000123977661
Math.fround(1.5) // 1.5
Math.fround(NaN) // NaN
```

## Polyfill

This can be emulated with the following function, if Float32Array are supported:

```function fround(x) {
var f32 = new Float32Array(1);
return f32[0] = x, f32[0];
}
```

## Browser compatibility

{{CompatibilityTable}}
Feature Firefox (Gecko) Chrome Internet Explorer Opera Safari
Basic support {{CompatGeckoDesktop("26")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
Feature Firefox Mobile (Gecko) Android Chrome for Android IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatGeckoMobile("26")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}}

## Revision Source

```<div>
<h2 id="Summary" name="Summary">Summary</h2>
<p>This operation returns the nearest simple-precision float representation of its single parameter.</p>
<table class="standard-table">
<tr>
<th class="header" colspan="2">Method of <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math"><code>Math</code></a></th>
</tr>
<tbody>
<tr>
<td>Implemented in</td>
<td>JavaScript 1.8.5+</td>
</tr>
<tr>
<td>ECMAScript Edition</td>
<td>ECMAScript 6th Edition</td>
</tr>
</tbody>
</table>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="syntaxbox">
<code>Math.fround(x)</code></pre>
<h3 id="Parameters" name="Parameters">Parameters</h3>
<dl>
<dt>
<code>x</code></dt>
<dd>
Any number.</dd>
</dl>
<h2 id="Description" name="Description">Description</h2>
<h2 id="Examples" name="Examples">Examples</h2>
<pre class="brush: js">
Math.fround(0) // 0
Math.fround(1) // 1
Math.fround(1.337) // 1.3370000123977661
Math.fround(1.5) // 1.5
Math.fround(NaN) // NaN
</pre>
<h2 id="Polyfill" name="Polyfill">Polyfill</h2>
<p>This can be emulated with the following function, if Float32Array are supported:</p>
<pre class="brush: js">
function fround(x) {
var f32 = new Float32Array(1);
return f32[0] = x, f32[0];
}
</pre>
<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2>
<div>
{{CompatibilityTable}}</div>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Firefox (Gecko)</th>
<th>Chrome</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
</tr>
<tr>
<td>Basic support</td>
<td>{{CompatGeckoDesktop("26")}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Firefox Mobile (Gecko)</th>
<th>Android</th>
<th>Chrome for Android</th>
<th>IE Mobile</th>
<th>Opera Mobile</th>
<th>Safari Mobile</th>
</tr>
<tr>
<td>Basic support</td>
<td>{{CompatGeckoMobile("26")}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}}</td>
</tr>
</tbody>
</table>
</div>
<p>&nbsp;</p>```