published · 9 min read
Node and Chrome Share an Engine and Disagree on Math.sin
Six JavaScript runtimes, 16,000 Math results, and the correctly rounded answers to score them against.

An AI agent drafted this from my projects, agents ran the measurements, and another agent checked the draft claim by claim against the code and the run records or briefs that were kept. The projects and opinions are mine.
Run this in Node, then in Chrome's console:
Math.sin(-87.173)
On my Mac, Node 22 prints 0.7114745101052029 and Chrome 156 prints 0.7114745101052028. Both run V8, just different versions of V8: Node 22 has 12.4 and Chrome 156 has 15.6. All the stable Nodes I tested, from 18 up to 26, the current LTS, print the first answer, and the Node 27 alpha, on V8 15.6, already prints Chrome's.

They differ by one unit in the last place, about 1 part in 10¹⁶, and for almost everything you'll ever write, that doesn't matter. For a few things it matters completely: a multiplayer game whose clients have to stay in lockstep, a physics replay, a test that compares outputs byte for byte, or a system that re-runs someone else's computation to check it got the same answer. I hit it while building that last kind, a project of mine called Verse (the last section has the story). The last bit can even help fingerprint a browser: Firefox added fdlibm versions of sin, cos and tan in 2021 for its anti-fingerprinting mode, and has used them by default on Mac and Linux since Firefox 134.
Six runtimes, 16,000 answers
The probe computes 8 Math functions on 2,000 fixed inputs, evenly spaced from about −100 to 640 (scaled or shifted for exp, log and sqrt; pow raises |x| + 0.5 to 1.37), and records each result's exact 64-bit pattern. Those answers were then scored against the true value, computed to 400 bits and rounded to the closest double. A "miss" means "not the closest double", which is a different thing from a bug.

All the misses in this chart are one double from the closest, or two for 45 of the tan misses in the bottom rows. That isn't a general limit: on some other inputs, found by searching for the worst cases, it gets a lot worse, and Deno 2.8's sin landed 1,063 doubles off and Bun's pow 253.
Repeat runs matched bit for bit, and so did runs with the JIT off and with hot functions forced into the top optimising tier (Node, Deno, Chrome, the jsc shell). Firefox's row comes from one pass. Chrome 157, released after these runs, gives the same bits on all 16,000. Bun 1.4.4, the latest release on 11 November, gives Bun 1.3's bits on all 16,000 in the chart. Firefox 160, released on 10 November, gives Firefox 159's bits on all 16,000. These numbers come from just my Mac on Apple silicon and a single set of inputs, so use them as a map of disagreement and don't rank anyone by them. A second run on 2,000 inputs between −1 and 2, without Firefox, kept the order: Chrome 2, Deno 568, Node 22 841, Bun 958. The Deno in the chart and in that second run is 2.8.1, the version on my Mac. Deno 2.9.8, the latest release on 11 November 2026, gives Chrome's bits on all 16,000 results of both sets.
Check your own
Paste this into any browser console, or run it with Node or Bun or Deno. It prints a fingerprint of 2,000 results for three functions, down to the last bit.
(() => {
const v = new DataView(new ArrayBuffer(8));
const hash = (h, x) => {
v.setFloat64(0, x);
for (let b = 0; b < 8; b++) h = Math.imul(h ^ v.getUint8(b), 16777619);
return h >>> 0;
};
const fns = {
sin: x => Math.sin(x),
tan: x => Math.tan(x),
pow: x => Math.pow(Math.abs(x) + 0.5, 1.37),
};
for (const [name, fn] of Object.entries(fns)) {
let h = 2166136261;
for (let i = 1; i <= 2000; i++) h = hash(h, fn(i * 0.37 - 100.123));
console.log(name, h.toString(16).padStart(8, '0'));
}
})();
On my Mac, with each Node line at its latest patch, the fingerprints came out like this:
macOS on Apple silicon:
sin tan pow
Node 18-22 c619d13e 283fddd8 879f0553
Node 24-26 c619d13e 283fddd8 8caa86d6
Deno 2.8 a5d88e5f a9c1c1db 8caa86d6
Deno 2.9 4c21d9e1 1b2f56ff 8caa86d6
Firefox 159 b143dad4 a9c1c1db 8caa86d6
Chrome 156 4c21d9e1 1b2f56ff 8caa86d6
Node 27 alpha 4c21d9e1 1b2f56ff 8caa86d6
Bun, jsc ccd09626 38a1c86d 8caa86d6
Other machines (Linux, Windows, Android, Intel) are likely to print values that aren't on this list, especially for pow. Firefox on Windows doesn't use fdlibm by default, so expect its sin and tan to differ too. I'd like to
hear which ones you get.
Four things decide the last bit
Four things stack to decide the last bit: the library, the engine version, a build option and the compiler.
JavaScriptCore mostly doesn't do this math itself. It calls the system libm for most fractional pow and for sin, cos, tan, exp, log, atan. On my Mac the results matched Python's math module and a C program fed identical input bits, on all 8 functions, with zero differences, so the 874 tan misses are Apple's. Bun and the macOS jsc shell are identical for that reason, and on Linux arm64 Bun matches glibc and misses 19 instead of 1,043. Safari uses the same engine, though I left Safari itself out of these runs.
The exception is pow with a whole-number exponent up to 1,000, which JavaScriptCore computes by repeated multiplication. Math.pow(b, 10) on the same bases differs from Chrome on 1,590 of 2,000.
V8's math file, ieee754.cc, is about 3,000 lines in the version Node 22 ships. In V8 15.6, which Chrome 156 runs, sin/cos/tan/exp/log/atan call LLVM's libm instead, and on V8's main branch the file is down to 245 lines. Chrome's near-perfect row comes from that.
An August 2026 accuracy study that searches for worst cases reports that LLVM libc 22.1.8 seems correctly rounded in double precision except for atan, atan2 and pow, and it didn't test V8's copy.
pow went a different way. Since V8 13.3 it has called the platform's own pow, so Chrome's 3 misses are Apple's, and they're identical in Chrome, Deno, Firefox and Bun because all four call Apple's pow on my Mac. Run Chrome with --js-flags=--no-use-std-math-pow and it scores 0 out of 16,000.
From late 2022 V8 used glibc-derived sin and cos by default in Chromium builds. Its own May commit measured that sin at 1,063 ulp in the worst case and called it "very off", and the option was removed in July. Deno
2.8 still has it switched on, and turning it off takes sin from 2 misses to 67. None of the official
Node builds I checked has it.
Node's tan and log differ from Deno 2.8's on 31 of these results, and it's the same
fdlibm code. Clang's default fuses a*b+c into one instruction wherever the target has one, which skips a rounding step, and ARM64 always has it.
Node's Apple silicon build leaves that on, and Deno 2.8's results match a build with it off. Rebuilding V8 12.4's ieee754.cc both ways
reproduces Node 22 on Apple silicon with fusing and Node 22 on x64 without it, bit for bit. So a single Node release gives different Math.sin bits on ARM and x64 (emulated on my Mac), on 10 of these 2,000 inputs. In a Node issue from July 2025, the reporter traced a difference between Node 22 on Apple silicon Macs and on x86_64 Linux to the same compiler default, and the issue was closed as stale in May 2026. Node's own Mac builds show the same split: 22.9.0 and 22.10.0 both report the same V8 version number, yet differ on 60 of these 16,000 results, and on every one 22.9.0 matches the unfused x64 build.

Node alone, each release line at its latest version, on my Mac:
Node 18, 20, 22 all identical
Node 24, 25, 26 all identical
22 vs 24 195 of 2,000 pow results changed, nothing else
26 vs 27 alpha 423 of 16,000 results changed, none of them pow
Of those 195, 192 landed on the closest double and 3 moved off it. It's a real improvement, and a golden file with a lot of Math.pow output would see it as a failure on the day you upgrade. The 423 are the same thing on a bigger scale: they bring the alpha level with Chrome on all 16,000.
Nobody is breaking a rule
IEEE 754, the floating-point standard, requires the basic operations (+ − × ÷ √, and fused multiply-add) to be correctly rounded, so for a given format and rounding mode there's exactly one right answer. JavaScript pins sqrt too: Math.sqrt is defined as the true square root rounded to the closest double, which is why it's zero in all the rows.
For the rest, sin, exp, log, pow among them, correct rounding is only recommended, and the JavaScript spec leaves these functions implementation-approximated. That was on purpose: the 1997 spec says "an implementor should be able to use the same mathematical library" that C programmers have. It even recommends fdlibm, the library behind the 190 exp misses in three rows (Deno 2.8, Firefox, Node). Getting the last bit right was long thought too expensive, so math libraries made different trade-offs. V8's commit messages show that changing, with LLVM's tan, log, exp correctly rounded on every input of its benchmark and faster than the fdlibm code they replaced. Node isn't buggy here, and neither is Bun.
Rust has the same split, inside one program
Compile a Rust program natively and then for WebAssembly:
| native | wasm32 | |
|---|---|---|
plain std (x.sin(), x.ln()…) |
0x1daf9de5440921cb |
0xe263278e1905d527 |
the libm crate |
0xe263278e1905d527 |
0xe263278e1905d527 |
(The cells are hashes over a batch of results, and the native std hash depends on your platform's library, so yours may differ.) Natively, x.sin() calls that library. On wasm32-unknown-unknown there is no platform library, so Rust brings a software implementation with it.
Getting the same bits everywhere
If exact reproducibility doesn't matter to you, do nothing. If it does:
- Treat a runtime upgrade as a math change. Pin the version along with the OS and the CPU architecture, and re-run your golden files on purpose. That may still not fix the bits: the study above reports that GNU libc and the Intel Math Library choose code by CPU at run time, and that one binary might give different results on different hardware.
- Use one implementation everywhere. In Rust, route math through the
libmcrate on every target. Bevy'slibmfeature andenhanced-determinismin Rapier and Avian do this, and all of them are opt-in. If you depend on exact results, the library version is part of your contract too. - Prefer the pinned operations. For results other than NaN, code that only uses
+ − × ÷ √is portable by the standard, as long as the compiler keeps them separate and nothing flushes subnormals to zero or uses x87's extra precision. Rust, JavaScript and plain WebAssembly arithmetic meet those conditions, though WebAssembly 3.0's relaxed SIMDrelaxed_maddmay fuse. C and C++ may not: with Apple clang's defaults,i*0.37-100.123gave a different result on 871 of these 2,000 inputs. NaN bits can differ even when the compiler keeps them separate: WebAssembly leaves a NaN result's sign non-deterministic outside its deterministic profile, and ECMAScript lets an engine pick the NaN encoding it writes to a buffer. - Test across engines in CI. Run a single probe across everything you ship to (runtime, OS, CPU) and fail the build if the bits differ.
Bruce Dawson's Floating-Point Determinism is still the best long read on the topic.
I hit it building Verse
I've been building Verse, a small system that runs a WebAssembly program on someone else's machine and then has an independent machine re-run it. If the outputs aren't byte-identical, the first machine is caught. That only works if machines that ran the program correctly always agree, so a sin that differs between x86 and ARM would turn into a false accusation. (A verifier on a different Wasmtime version can't cause that: it declines to judge.)
So Verse builds the transcendental functions only from + − × ÷ √, and ships a conformance suite of 255 test vectors that comes out identical on Wasmtime, V8 and JavaScriptCore. Verse's CI greps those functions and llm.rs for mul_add (Rust's fused multiply-add), and that grep once matched the comment in llm.rs that spells out the ban.
Verse is at https://www.versemesh.org.