clojurescript 2026-05-12

https://cljs.github.io/api/cljs.math/floor - the docs say Returns the largest double but actually this will return an integer, in contrast to the JVM version which will return a double.

js doesn't have integers at all

I mean technically it just has one number type for both

True, it's technically a number type but https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor mentions integer. I was moving some code from cljs to cljc and noticed this difference in behaviour.

1 === 1.0 true

js just doesn't care 😛

I didn't either, until my tests started failing 🙂

👀 1

cljs.user> (cljs.math/floor 2.5)
2
cljs.user> (Math/floor 2.5)
2
vs
user> (clojure.math/floor 2.5)
2.0
user> (Math/floor 2.5)
2.0

clj relies on the jvm impl of floor, cljs relies on the js impl

same as regex syntax

Indeed, I checked the source code, but the docs say double, maybe that's the only issue here. But it's something I came across when moving this code to cljc and testing on the JVM, as I was incorrectly relying on that being an integer and passing it to even? later in my project.

oh right, you were talking about the docstring, my apologies