getFloat32() reads four bytes from a DataView as a 32-bit floating point number (single precision) and returns it as a normal JavaScript Number. A 32-bit float keeps about 7 significant digits and reaches about ±3.4 × 1038, which is plenty for sensor values, audio and 3D coordinates. Because JavaScript Numbers have more precision, values like 0.1 show their rounding when read back.
Reads the 4 bytes starting at byteOffset in big-endian order (most significant byte first) and returns a 32-bit floating point number (single precision).
view.getFloat32(byteOffset, true)
Reads the same 4 bytes in little-endian order (least significant byte first), the order used by most file formats from PCs, such as WAV and BMP.
Part of the original DataView from ES2015, so every modern browser and runtime has it. Unlike a Float32Array, a DataView has no alignment rule: getFloat32() works at any byte position, even one that is not a multiple of 4.
Library declarations
JavaScript
DataView.prototype.getFloat32(byteOffset)
DataView.prototype.getFloat32(byteOffset, littleEndian)
// returns a Number: about -3.4028234663852886e38 to 3.4028234663852886e38, about 7 significant digits
// reads 4 bytes starting at byteOffset (counted from the start of the view)
// needs byteOffset + 4 <= view.byteLength, else RangeError
// littleEndian: false or left out = big-endian
Parameters
Parameter
Description
byteOffset
Where to start reading, counted in bytes from the start of the view (not of the underlying buffer). It is converted to a whole number, so 1.9 means 1 and "2" means 2. All 4 bytes must fit: byteOffset + 4 may not be larger than view.byteLength. A negative or too-large offset throws a RangeError.
littleEndian
Optional. Leave it out (or pass false) for big-endian: the most significant of the 4 bytes comes first. Pass true for little-endian: the least significant byte comes first. Any truthy value, such as 1, also means little-endian.
Return Value
Return Value
Description
Number
The 4 bytes decoded as a 32-bit floating point number (single precision) and turned into a normal JavaScript Number (range about -3.4028234663852886e38 to 3.4028234663852886e38, about 7 significant digits). It can also be NaN, Infinity, -Infinity or -0.
JavaScript Examples
Example 1 — Read a Packet With Type, Length and a Float Value
A sensor sends 7 bytes: a 1-byte type, a 2-byte length and a 4-byte float temperature, packed with no gaps.
JavaScript
const packet = new Uint8Array([0x01, 0x00, 0x04, 0x41, 0xac, 0x00, 0x00]);
const view = new DataView(packet.buffer);
const type = view.getUint8(0);
const length = view.getUint16(1);
const value = view.getFloat32(3);
console.log("type " + type + ", " + length + " bytes"); // type 1, 4 bytes
console.log("temperature: " + value + " C"); // temperature: 21.5 C
Store 0.1 in 4 bytes. setFloat32() must round 0.1 to the nearest 32-bit float, because 0.1 has no exact binary form.
Read it back and look closely. getFloat32() returns that rounded value as a 64-bit Number, so the extra digits 0.10000000149011612 become visible and === 0.1 is false.
Display and compare sensibly.toFixed(2) prints 0.10 for people, and Math.fround(0.1) produces the same float32 value for an exact comparison.
Example 3 — A Little-Endian Float From a Device
A device sends the float -12.5 low byte first. Read it with and without true.
Bytes from a little-endian device. The 4 bytes 00 00 48 c1 are the float -12.5 (0xc1480000) stored low byte first.
Ask for little-endian.getFloat32(0, true) puts the bytes back in the right order and gives -12.5.
The wrong order looks like almost zero. Read big-endian, the same bytes form a tiny positive number around 1e-41: a typical sign of a byte-order mistake.
Compatibility
Browser & Runtime Support
getFloat32() has been part of JavaScript since ES2015, when DataView itself was standardised.
✓ ES2015 · Baseline
DataView.prototype.getFloat32()
Works in every modern browser and in Node.js, Deno and Bun. It runs on a normal ArrayBuffer, so no special page setup is needed.
100%Modern browser support
Google ChromeModern versions · Desktop & Mobile
Full support
Mozilla FirefoxModern versions · Desktop & Mobile
Full support
Apple SafariModern versions · macOS & iOS
Full support
Microsoft EdgeModern versions · Chromium
Full support
OperaModern versions
Full support
Samsung InternetModern versions · Android
Full support
Internet ExplorerRetired browser · not tested here
Legacy
Node.jsCurrent releases · checked on Node 24
Supported
DenoCurrent releases
Supported
BunCurrent releases
Supported
getFloat32()All modern engines
Bottom line: Safe to use without a fallback. It also works on a SharedArrayBuffer, but a normal ArrayBuffer is all you need.
Frequently Asked Questions
About 7 significant decimal digits. Integers are exact only up to 16777216; above that, some whole numbers are skipped.
The bytes hold the nearest 32-bit float to 0.1. getFloat32() converts it to a 64-bit Number, which shows the small error that the 32-bit format had.
It returns Infinity, -Infinity or NaN, exactly as the 32-bit float pattern says.
Yes. DataView has no alignment rule, which makes it ideal for packed binary packets.
Use the one that matches how the data was written. If the format stores 4-byte floats, use getFloat32(); if it stores 8-byte doubles, use getFloat64().