This series began with What runs your JavaScript?: an engine, inside a host (Node.js is the kind of host called a runtime), and a specification that defines the language. Whose maths is it? showed that for Math.sin, Math.cos, and Math.exp, the specification describes an ideal answer and leaves the last bits to each engine—its word is implementation-approximated—and that engines fill that room differently.1 Down to the last bit showed why stdlib gives one answer on engines that don't agree on Math, checking each run by its digest, a SHA-256 hash of everything the code printed.
This post holds one runtime still and changes what's beneath it, one layer at a time: the engine and its C library, then the runtime's release, then the processor. The JavaScript engine's own Math.sin moves with each change, and stdlib's sin doesn't. For copies of an app that have to agree with no server between them, that difference decides whether they would.
One runtime, one engine at a time
Bare is the runtime underneath Holepunch's peer-to-peer apps, a "small and modular JavaScript runtime for desktop and mobile," whose standard library is "opt-in, not built in."2 In Holepunch's sense, an app is the code you give the runtime, split into a portable core and a thin user-interface host that "changes per platform," with the core as "code that should be identical on every device."3 A peer is one copy of an app, on one person's device, working with other copies directly, with no server between them. No third party checks the core's answers. Each peer computes its own state and publishes it, and if two published values differ, nothing tells either peer which one to believe.4 What a peer publishes here is a digest of its state: two peers running the same core on the same inputs should publish the same one, and if they don't, they've stopped agreeing on what happened.
Bare lets the engine change while the runtime stays put, which is as close to a controlled experiment as JavaScript runtimes get. Bare's engine is picked when Bare itself is compiled, through a build option, BARE_ENGINE, with no change to Bare's source. Bare "can be compiled against V8 (the default), QuickJS via libqjs, or JavaScriptCore via libjsc," and the app on top doesn't change when the engine does.5 So one Bare source tree gives a V8 Bare and a QuickJS Bare—Bare compiled against QuickJS through libqjs, Holepunch's library that connects QuickJS to Bare—with the same app on top of each.
The app here is a small simulation: 100 particles, a fixed random seed, and 10,000 ticks, after which its whole state goes into one digest, so two runs with the same digest ended on the same bits. It's written twice. The Math simulation calls the JavaScript engine's own Math.sin, Math.cos, and Math.exp; the stdlib simulation calls stdlib's sin, cos, and exp, and is otherwise the same, seed included. Either simulation's digest is what a peer running it would publish.6
Every tick, the simulation draws a fresh angle for each particle from its seeded pseudorandom number generator, and takes the sine and cosine of it: Math.sin and Math.cos in the Math simulation, stdlib's sin and cos in the other. So each tick makes 100 sine calls, one per particle, and 10,000 ticks make a million, on the same million angles, in the same order, whatever runs them.7 Any one call has the same input for every peer, so the only thing that can differ is the answer. The call to follow is call 365: tick 3's particle 65.8
Here the engine changes underneath one runtime, and the code on top is a whole app. Down to the last bit ran stdlib's maths on many engines, one at a time: in browsers, in engine shells, and inside other runtimes. Node.js 24.19.0, on V8 13.6, is the reference for the stdlib digest, held at that one release throughout: under Node.js, the stdlib simulation's digest is cb8e6954..., and every other run is checked against that.9

A different engine
Bare's docs say the app doesn't change when the engine does, and it doesn't. What Whose maths is it? showed still holds, though: two engines don't compute Math.sin the same way. Swap V8 for QuickJS under the same Bare, and the Math simulation's digest moves.
On Bare 1.38.0, the V8 Bare and the QuickJS Bare agree on the first 365 Math.sin calls, through tick 3's particle 64, and then part: call 365 is the first of 1,360 Math.sin calls, out of the million, where their answers differ.10 The two answers come from different code. Bare 1.38.0's V8, version 15.7, takes Math.sin from LLVM's maths library, LLVM's libc, built into V8. The QuickJS Bare's comes from the C library: QuickJS binds Math.sin, Math.cos, and Math.exp straight to the C library's functions, and Holepunch's libqjs leaves that binding alone.11 On the Linux virtual machine these ran on, that's glibc (the GNU C library). One release can't show which of the two moved at call 365; the next section can.
That first difference is enough. The simulation feeds each tick's positions into the next, so a difference in the last bits of call 365 is carried through every tick after it, and the Math simulation's digest comes out different. The stdlib simulation's doesn't:
Math stdlib
Bare 1.38.0 on V8 fb6727b4... cb8e6954...
Bare 1.38.0 on QuickJS 78a0dcc0... cb8e6954...
A third engine needed only that one build option. Compiled against QuickJS-ng, a fork of QuickJS, through Holepunch's libqjsng, Bare 1.38.0 built with no patch to either, and its Math simulation gave the same digest as the QuickJS Bare's. Its stdlib digest was cb8e6954..., unchanged.12 Two different engines gave one Math answer, and what they share is the glibc both hand their maths to.
Is the QuickJS Bare's answer really the C library's, then? Changing only the C library answers it. Built against musl instead of glibc, on the same x86_64, the QuickJS Bare gives a different Math digest again, and this time it's stdlib's own, cb8e6954...: musl's sin and cos happen to give stdlib's bits on x86_64, on all of the simulation's million angles.13 The QuickJS Bare's Math digest follows whichever C library is underneath; stdlib's follows none of them.
Two peers, then, one on the V8 Bare and one on a QuickJS Bare, running the same core from the same seed, would part at call 365 and publish different Math digests after 10,000 ticks.
A newer release
Upgrading Bare changed its maths, too, though nothing in Bare did the changing, and the upgrade shows which side moved at call 365.
I first ran the simulation in October 2026, on Bare 1.36.0, whose V8, version 14.8, carried its own copy of glibc's sin, compiled without fused multiply-add (FMA). When I came back to run it again in November, Bare was at 1.38.0, so the rerun tested an upgrade too. Take the V8 Bare at both releases, on the same machine, running the same core. The two agree on every Math.sin call before call 365, and there they part. It's the call where the V8 and QuickJS Bares part, too. At that call, the older V8 Bare and the QuickJS Bare still give the same answer, and only the newer V8 gives another:
Math.sin, call 365
Bare 1.36.0 on V8 14.8 same as the QuickJS Bare
Bare 1.38.0 on QuickJS same as V8 14.8
Bare 1.38.0 on V8 15.7 differs from both
Over the million calls, the two V8 Bares differ on 1,420 Math.sin results,14 and the upgrade alone moved the Math simulation's digest. The stdlib simulation's stayed the same:
Math stdlib
Bare 1.36.0 on V8 14.8 8c5e078f... cb8e6954...
Bare 1.38.0 on V8 15.7 fb6727b4... cb8e6954...
Node.js and the QuickJS Bare, run beside them, gave the same Math digests in October and in November. A peer that upgraded and a peer that didn't would part at call 365, as surely as a V8 peer and a QuickJS peer would.
So the difference at call 365 doesn't come from QuickJS, or from Bare. It comes from V8 15.7, which computes Math.sin, Math.cos, and Math.exp with LLVM's maths library. Bare 1.38.0's Math.sin matches V8 15.7's own shell, d8, bit for bit, on every one of the simulation's angles.15 Nor is the platform what moved it: Bare 1.38.0 (V8 15.7) gives the same Math.sin, Math.cos, and Math.exp bits on five platforms, and the same Math digest on all five. The V8 Bare's Math changed once, between Bare 1.36.0 (V8 14.8) and Bare 1.38.0 (V8 15.7), and not from one platform to another.16
Call 365 is where this post meets the two before it. Whose maths is it? showed engines filling the specification's room for Math in different ways, V8's move to LLVM's maths library among them. Down to the last bit showed Node.js's Math moving from one release to the next while stdlib's answers held. Call 365 is V8's move to LLVM's maths library again, seen in one runtime held still, at one input. Nothing is broken, in Bare or in V8. Math.sin is implementation-approximated, so its last bits are each engine's to choose, and taking them from LLVM's maths library is one engine's trade-off inside the room the specification leaves.

The same binary, a different processor
Even the same QuickJS Bare binary, on the same C library, can give a different Math.sin, depending on which instructions the processor reports. The difference from V8 is where the choice is made: V8 15.7's Math.sin is compiled into V8 when V8 is built, while the QuickJS Bare's is chosen by glibc each time it loads, from what the processor reports.
Changing the processor changes nothing at call 365, so to see what it does change, follow a different call. glibc carries several compiled builds of sin, and picks one as it loads, by what the processor says it can do. Two of glibc's builds matter here: on x86_64 it takes the build with FMA when the processor reports FMA and Advanced Vector Extensions 2 (AVX2), and a build without FMA otherwise. A fused multiply-add rounds once where a multiply and an add round twice, so on some inputs the two builds give different bits.
glibc also has a setting that hides those features from it, so that it loads the build without FMA even on a processor that has it. Run the same QuickJS Bare binary both ways, on the same machine, and the two runs agree on every call until the first where either Math.sin or Math.cos differs: call 1,625, in tick 16.17 The machine reports FMA and AVX2, so unmasked, glibc loads the FMA build. The Math simulation's digest moves with the setting, and the stdlib simulation's doesn't:
Math stdlib
Bare 1.38.0 on QuickJS, unmasked 78a0dcc0... cb8e6954...
Bare 1.38.0 on QuickJS, masked 8c5e078f... cb8e6954...
Before the upgrade, that one rounding difference was the whole difference between the V8 Bare and the QuickJS Bare. V8 14.8's copy of glibc's sin was compiled without fused multiply-adds, so the two Bares weren't running two different sin functions but one, glibc's, compiled two ways. With the features masked, the QuickJS Bare gives V8 14.8's sin and cos bits on every angle, and its Math digest, 8c5e078f..., is the 1.36.0 V8 Bare's:
| Comparison | Math.sin |
Math.cos |
First call where either differs (tick) |
|---|---|---|---|
| Bare 1.38.0: V8 15.7 against QuickJS | 1,360 | 1,447 | 365 (3) |
| The V8 Bare: 1.36.0 against 1.38.0 | 1,420 | 1,535 | 365 (3) |
| The 1.38.0 QuickJS Bare: unmasked against masked | 672 | 690 | 1,625 (16) |
| Bare 1.36.0's V8 14.8 against the 1.38.0 QuickJS Bare | 672 | 690 | 1,625 (16) |
| The same, FMA and AVX2 masked | 0 | 0 | none |
So take two peers on the same QuickJS Bare binary, the same operating system, and the same glibc, one on an x86_64 processor that reports FMA and AVX2 and one on a processor that doesn't. They would part at call 1,625 and publish different Math digests.18 Their stdlib digests would match, as they did on the one machine under both settings.19
The digest that didn't move
Run through the same changes—a different engine, a different C library, a newer release, a different platform, and the processor's features hidden from glibc—the stdlib simulation gave one digest every time.
In the stdlib simulation, call 365 is stdlib's sin, the same JavaScript on every runtime, and so is every other call. The digests say the rest.
| Step | Configuration | Math |
stdlib |
|---|---|---|---|
| Reference | Node.js 24.19.0 (V8 13.6), Linux x86_64, glibc | b8aa2ca3... |
cb8e6954... |
| Engine | Bare 1.38.0 on V8 15.7, Linux x86_64, glibc | fb6727b4... |
cb8e6954... |
| Engine | Bare 1.38.0 on QuickJS, Linux x86_64, glibc | 78a0dcc0... |
cb8e6954... |
| Engine | Bare 1.38.0 on QuickJS-ng, Linux x86_64, glibc | 78a0dcc0... |
cb8e6954... |
| C library | Bare 1.36.0 and 1.38.0 on QuickJS, Linux x86_64, musl | cb8e6954... |
cb8e6954... |
| C library | Bare 1.38.0 on QuickJS, Linux arm64, musl | 67dfd914... |
cb8e6954... |
| Release | Bare 1.36.0 on V8 14.8, Linux x86_64, glibc | 8c5e078f... |
cb8e6954... |
| Platform | Bare 1.38.0 on V8 15.7, on each of five platforms | fb6727b4... |
cb8e6954... |
| Processor | Bare 1.38.0 on QuickJS, Linux x86_64, glibc, FMA and AVX2 masked | 8c5e078f... |
cb8e6954... |
Across every configuration run, there were three engines, two runtimes, Linux and macOS, x86_64 and arm64, three C libraries, and four versions of V8, either side of its move to LLVM's maths library. The stdlib simulation's digest stayed the same through all of them. The Math simulation's didn't: the October configurations alone gave six different Math digests, not all of them in the table above, and 1.38.0 added more.20
The reason is in what the stdlib simulation calls. Across the stdlib packages the simulation loads, the only Math functions called are Math.floor and Math.round, which the specification fixes exactly, and Math.random, which picks a default seed and goes unused when a seed is given. Everything else is arithmetic, which the specification fixes exactly too. So stdlib's sin at call 365 reaches only operations every conforming engine must do the same way: the reason Down to the last bit gave for single functions, now for a whole app.21
Two peers running the simulation with stdlib's maths, on Bare with any of the three engines here, would publish the same digest on every configuration in the table, with no server to compare against.22
Two halves of one idea
Bare runs the core that's meant to be identical on every device, and stdlib aims to make that core's answers identical too. Across every setup run here, the stdlib simulation's answers held the same.
That isn't a fix for Bare. Bare leaves maths to the engine, the way it leaves out a bundled standard library on purpose: you bring what your code needs.23 The simulation needed little from Bare.24 stdlib is one more thing you can bring. Its JavaScript is written to need nothing from the engine's maths beyond the operations the specification fixes, which is why call 365 came back the same under stdlib wherever it ran, and why the digest at the end did too.
All of this ran on Linux and macOS, on x86_64 and arm64, natively, in virtual machines, and in containers. Nothing ran on a phone, and no two peers connected: every digest here is what a peer would publish.
Bare runs an app's portable core wherever the app goes. Write that core's maths with stdlib, and it will give the same answers everywhere as it did here.
While some folks might find fault in stdlib rolling its own maths functions, the fact-of-the-matter is that stdlib offers portability in ways other maths libraries, and JavaScript engines through their Math namespaces, currently cannot. So when robustness and reproducibility matter, reach for stdlib. When and why it matters will be the subject of a subsequent post.
Mara Averick is a developer advocate at Quansight and contributor experience lead for stdlib.
stdlib is an open source software project dedicated to providing a comprehensive suite of robust, high-performance libraries to accelerate your project's development and give you peace of mind knowing that you're depending on expertly crafted, high-quality software.
If you've enjoyed this post, give us a star 🌟 on GitHub and consider supporting the project. Your contributions and continued support help ensure the project's long-term success and are greatly appreciated!
Acknowledgments
This work was supported in part by the National Science Foundation under Award No. 2449410.
Disclaimer: Any opinions, findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.
-
ECMA-262, 17th edition, §21.3.2, Function Properties of the Math Object; the term is defined in §4.4.1. ↩
-
Bare's README, line 8, at
853ff35; "The standard library is opt-in, not built in,"migrating-from-nodejs.mdx, line 16. Bare does build in a small core of its own modules; what it leaves out is Node.js's. ↩ -
Holepunch's docs, read at
holepunchto/pear-docs57383c44, the source of the published docs: the core as "code that should be identical on every device,"bare-on-native.mdx, line 10; the core and the user-interface host that "changes per platform,"how-the-stack-fits-together.mdx, line 69. ↩ -
Holepunch's peers find each other through HyperDHT, which "uses a series of holepunching techniques" (
hyperdhtREADME, line 13, at7b56e04). Nothing peer-to-peer ran for this post: no two peers connected, and every digest in it is one core run in one configuration, compared with the others afterwards. ↩ -
bare-runtime.mdx, line 81: "Your application and addons don't change between engines."BARE_ENGINEis documented in Bare's README at v1.38.0, line 157. Different engines on real devices are Holepunch's own design, too: Bare Kit offers QuickJS on Android and JavaScriptCore on iOS (bare-kit.mdx, lines 45–49), though neither was run here. ↩ -
Seed 1234, 10,000 ticks, 100 particles. The
Mathsimulation is the stdlib simulation with stdlib'ssin,cos, andexpswapped forMath's, and with the same seeded pseudorandom number generator, so only those three calls can differ. It's a small lockstep simulation, reused across this series' experiments. The simulation is in its companion repository'ssimulation/folder, withmaketo run it on Node.js and Bare, and the companion repository holds every transcript behind this post, one folder per claim. ↩ -
The angles come from stdlib's Mersenne Twister, seeded with 1234, scaled to [0, 2π), not from the particles' state, so a difference in one call's answer never changes a later call's input. The simulation also calls
Math.exponce, on-0.01, where every runtime gives the same bits. ↩ -
Calls and ticks are counted from zero, so call 365 is the 366th sine call, and tick 3 is the fourth tick. A call number is a position in the sequence of angles, so call 579 is the 580th cosine, as call 365 is the 366th sine. ↩
-
The full digest is
cb8e6954ab0c7f62cf6f1a8e4abf56ec6d1d9f0c59cd1e8a906d30df68e88500, from Node.js 24.19.0. The runs were on a Linux x86_64 virtual machine (Ubuntu 24.04.5, glibc 2.39) and on macOS arm64, on 27 October 2026 with Bare 1.36.0 and on 24 November 2026 with Bare 1.38.0. In October, Linux x86_64 containers (Debian 12; Alpine 3.24.1) ran on the virtual machine; in November, Linux arm64 containers and emulated Linux x86_64 containers (Debian 12; Alpine 3.24.1) ran on macOS arm64. Bare has had a release since; nothing here was run on it. ↩ -
And 1,447 of the million
Math.coscalls, whose first difference is call 579, in tick 5. One comparison run, on Linux x86_64, 24 November 2026. The comparison run and the per-call probe. ↩ -
quickjs.cbinds each withJS_CFUNC_SPECIAL_DEF, e.g.,JS_CFUNC_SPECIAL_DEF("sin", 1, f_f, sin )(lines 49208–49212 at84e723f).libqjsapplies its own patches to QuickJS when it builds, and none of them touches those lines. ↩ -
QuickJS-ng 0.18.0, through
libqjsngat5c593d1, on Linux x86_64, run twice. ↩ -
musl 1.2.6, linked statically into the QuickJS Bare. The x86_64 result is the same at Bare 1.36.0, in an Alpine container, and at 1.38.0, run natively. On arm64 it isn't: there, musl's
sinandcosdiffer from stdlib's on 6,813Math.sinand 5,406Math.cosresults of the million, and theMathsimulation gives a digest of its own. The cause is attributed, from disassembly, to fused multiply-adds in that build of musl; no musl was rebuilt to prove it. ↩ -
The same comparison run as the 1,360. ↩
-
V8's tracking bug for the move to LLVM's maths library gives its aim as "consistent math results around configs"; Whose maths is it? tells the move in full. At V8 15.7.112.12,
src/base/ieee754.ccdefinessinas a one-line call into LLVM's maths library (line 229 ata4889e0), withcosandexpbeside it, and no#ifaround any of them. Bare 1.38.0 gives the sameMath.sinandMath.cosas V8's own shell, d8, at 15.7.112, on all of the simulation's million inputs. At Bare 1.36.0, Node.js and Bare differed for another reason: a V8 build option that compiled in a copy of glibc'ssinandcos, set in Bare's build of V8 and left out of Node.js's. From V8 15.0 that option is gone, and they differ by V8 version instead. ↩ -
A Linux x86_64 virtual machine (Ubuntu 24.04.5), macOS arm64, macOS x86_64, translated, on macOS arm64, a Linux arm64 container (Debian 12), and a Linux x86_64 container, emulated, on arm64 (Debian 12), each run twice, over a million inputs per function. Three functions were measured:
Math.sin,Math.cos, andMath.exp. ↩ -
glibc's order of preference on x86_64 is the FMA build, then FMA4, AMD's four-operand fused multiply-add, then AVX, then SSE2, the baseline every x86_64 processor has (
ifunc-avx-fma4.h, lines 25–32, at glibc 2.39'sef321e2). The masked runs used glibc's own setting for this,GLIBC_TUNABLES=glibc.cpu.hwcaps=-AVX2,-FMA, and read back which build each process had actually loaded, rather than trusting the setting. ↩ -
Measured on one machine under both settings; what that means for two machines is inferred. ↩
-
The same rounding difference is the likeliest reason musl's
sinandcosleave stdlib's bits on arm64 and not on x86_64, and why Node.js's official arm64 builds give differentMathresults from its x86_64 build; there, it's fixed when the library is compiled rather than chosen as it loads. musl's is attributed from disassembly, and Node.js's from disassembly of its macOS arm64 build, which its Linux arm64 build matches result for result; neither was proven by a rebuild. ↩ -
The results table of 14 configurations, each with its transcripts. The four V8 versions are 13.6 (Node.js 24.19.0), 14.6 (Node.js 26.12.1, on the Mac in October), 14.8, and 15.7, and the three C libraries are glibc, musl, and macOS's own. Six
Mathdigests is the count across the 1.36.0 configurations; Bare 1.38.0's V8 and arm64 musl gave new ones. Each Bare release was the latest when it ran: 1.36.0, released on 21 October 2026, ran on 27 October, two days before 1.36.1; 1.38.0, released on 17 November, ran on 24 November, three days before 1.39.0. ↩ -
Found by searching the code of every stdlib package on the simulation's digest path for
Math.. That's a reading of the specification against stdlib's code, and the runs bear it out on every engine here. ↩ -
This is about stdlib's JavaScript. stdlib's native add-ons go through C, so they share C's differences. ↩
-
stdlib's benchmark harness runs on all three Bares too. It expects a process, an output stream, and a module system from its runtime, and Bare supplies them as modules you import. Holepunch's docs give three routes from Node.js code to Bare: the compatibility layer,
bare-node-runtime;bare-nodealias wrappers; and directbare-*module swaps (migrating-from-nodejs.mdx, lines 58–62). The V8 Bare takes the first. The QuickJS Bare imports onlybare-process's global and an import map, a mix of the first and third, and the QuickJS-ng Bare runs either setup. Both setups carry one override, becausebare-eventsdeclares its emitter as a class and the harness calls it the way JavaScript did before ECMAScript 2015,EventEmitter.call( this )(lib/runner/index.js, line 51, at1309e9c). The harness setups and their transcripts. ↩ -
The simulation's runner needs only a SHA-256:
bare-cryptowhere Bare can load native add-ons, and one written in plain JavaScript on the musl build, which can't. It installs acrypto.subtle.digestbacked by whichever it has, because no Bare here hasglobalThis.crypto, and leaves the hashing code itself unchanged. Nothing on the digest path needed an alias for a Node.js built-in: one package the simulation lists as a dependency,@stdlib/fs-read-file, fails under Bare without an alias forfs, but nothing on the digest path loads it. ↩
Top comments (0)