cljs-dev

borkdude 2026-01-26T13:30:41.207999Z

I think I found a bug with pr-ing a negative zero number in CLJS: JVM Clojure:

user=> (prn -0.0)
-0.0
CLJS:
cljs.user=> (prn -0.0)
0
This causes a real bug for me. Issue+patch welcome @dnolen?

đź–¤ 1
âś… 1
2026-01-29T10:20:07.227669Z

@quoll btw, are you a contact point for minor improvements to clojure.math?

quoll 2026-01-29T10:20:54.611019Z

It's part of ClojureScript proper now, which has always required David's approval, but sure.

quoll 2026-01-29T10:21:15.298149Z

Did I miss something?

borkdude 2026-01-29T10:32:49.761949Z

FWIW, CLJS's clojure.math mirrors Clojure JVM's clojure.math so I think that should be the first point of contact

borkdude 2026-01-29T10:33:06.306129Z

as in #clojure-dev

👍 1
🙏 1
2026-01-29T10:34:59.027849Z

I wouldn’t say that you missed anything, but there are a couple of “nice to haves” that I would like to drop in if it isn’t objectionable to the team. 🙂

quoll 2026-01-27T08:26:59.599179Z

I remember hitting this one when working on math. The simplest approach is updating the cond in pr-writer-impl with:

(number? obj)
        (-write writer
          (cond
            (js/isNaN obj) "##NaN"
            (identical? obj js/Number.POSITIVE_INFINITY) "##Inf"
            (identical? obj js/Number.NEGATIVE_INFINITY) "##-Inf"
            (js/Object.is obj -0.0) "-0"
            :else (str_ obj)))
But I didn't know how well it could go over at the time. (updating core, and potentially breaking user code)

quoll 2026-01-27T08:27:03.041869Z

It's possible to use (and (zero? obj) (neg? (math/copy-sign 1 obj))) but that's utterly irrational 🙂

borkdude 2026-01-27T08:35:13.870469Z

I've already applied a patch and indeed landed on the same approach.

borkdude 2026-01-27T08:36:04.947899Z

What's also possible is: (neg? (/ obj)) - I came across this elsewhere. http://Object.is is only available since ES6 which is now the base target for CLJS since the last few releases, we couldn't use that before.

quoll 2026-01-27T09:13:58.539109Z

You can also use (identical? ##-Inf (/ 1 obj))

borkdude 2026-01-27T09:17:30.595279Z

I think http://Object.is is the most clearest :)

dnolen 2026-01-26T13:43:53.669149Z

yes

borkdude 2026-01-26T22:07:46.269579Z

https://clojure.atlassian.net/browse/CLJS-3471 Also discovered tools.reader doesn't read negative zero correctly in CLJS. I'll make a separate ticket for that and fix that tomorrow

đź–¤ 1
borkdude 2026-01-26T22:08:05.958039Z

There's also this one I mentioned, less important: https://clojurians.slack.com/archives/C07UQ678E/p1769252416934779