clojurescript

ajk 2026-05-12T06:10:41.305049Z

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.

thheller 2026-05-12T06:12:21.149189Z

js doesn't have integers at all

thheller 2026-05-12T06:13:01.131699Z

I mean technically it just has one number type for both

ajk 2026-05-12T06:16:58.219129Z

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.

thheller 2026-05-12T06:17:44.896819Z

1 === 1.0 true

thheller 2026-05-12T06:17:50.675289Z

js just doesn't care 😛

ajk 2026-05-12T06:18:09.515079Z

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

👀 1
2026-05-12T11:32:32.763959Z

what's the test?

ajk 2026-05-12T12:05:20.538069Z

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

2026-05-12T12:08:46.241929Z

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

2026-05-12T12:08:57.438069Z

same as regex syntax

ajk 2026-05-12T12:12:17.117369Z

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.

2026-05-12T13:16:30.769969Z

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