This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-03-03
Channels
- # ai (1)
- # announcements (1)
- # beginners (5)
- # biff (23)
- # clojure (3)
- # clojure-europe (4)
- # clojure-norway (22)
- # clojurescript (21)
- # data-science (1)
- # datascript (5)
- # graalvm (2)
- # gratitude (2)
- # humbleui (4)
- # hyperfiddle (10)
- # lsp (46)
- # off-topic (15)
- # pedestal (1)
- # reitit (3)
- # shadow-cljs (12)
- # sql (4)
I was discussing Clojure with someone on Reddit and they told me there are no unsigned 64-bit integers in Java and consequently in Clojure. Ho do you solve it? Or just using signed 64-bit numbers? Looks like Clojure silently fallbacks to BigInt:
user=> (def x 2)
#'user/x
user=> (type x)
java.lang.Long
user=> (def y 18446744073709551615)
#'user/y
user=> (type y)
clojure.lang.BigInt
1. Use the signed numbers to emulate the bigger unsigned numbers see here https://stackoverflow.com/questions/397867/port-of-random-generator-from-c-to-java/397997#397997 2. Use a language with 64 bit unsigned support like Rust or Go or C++ But I guess what do you mean by “how do you solve it”?
The Long class has some operations that may help with treating them as unsigned, though it may be a bit clunky and Bailey is right in raising the issue of using the right tool (language) for the job https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Long.html (ctr+f unsigned)