Re: bit-wise operators for bigint in Clojure

2020-06-02 Thread Niels van Klaveren
Clojure often leaves implementations to the backing platforms, and 
Clojurescript probably has no difference in the methods of the different 
numerical types.
Java does, so you'd have to fall back on that. Something like:

(defn big-or
  [f & r]
  (reduce (fn [acc v] (.or acc (biginteger v))) (biginteger f) r))

(defn big-and
  [f & r]
  (reduce (fn [acc v] (.and acc (biginteger v))) (biginteger f) r))

(defn big-xor
  [f & r]
  (reduce (fn [acc v] (.xor acc (biginteger v))) (biginteger f) r))

A lot of (mathemathical) operations need falling back to the platform, and 
this is by design for clojure. There are however libraries that are 
intended to abstract away the differences, and one of those for math is 
clojure.math.numeric-tower.

A numeric type independent implementation for bitwise operations would be a 
fitting pull request there.


On Tuesday, May 26, 2020 at 6:39:51 PM UTC+2, Harmon Nine wrote:
>
> Hello.
>
> I noticed a post about this from 2013, so doing a bump.
>
> The bit-wise operators appear to be supported for 'bigint' in 
> ClojureScript, but not in Clojure.  Is support for these operations on 
> 'bigint' in Clojure a future enhancement?
>
> Thanks :)
> -- Harmon
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/e8fe6493-4458-4a60-b9f5-902dbc2abf07%40googlegroups.com.


Re: bit-wise operators for bigint in Clojure

2020-06-02 Thread Niels van Klaveren
Clojure 1.10:

(and 4N 8N (bigint Integer/MAX_VALUE))
=> 2147483647N

(or 4N 8N (bigint Integer/MAX_VALUE))
=> 4N


On Tuesday, May 26, 2020 at 6:39:51 PM UTC+2, Harmon Nine wrote:
>
> Hello.
>
> I noticed a post about this from 2013, so doing a bump.
>
> The bit-wise operators appear to be supported for 'bigint' in 
> ClojureScript, but not in Clojure.  Is support for these operations on 
> 'bigint' in Clojure a future enhancement?
>
> Thanks :)
> -- Harmon
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/746ef4a0-84e4-4372-af98-3bb22bbb44c8%40googlegroups.com.


Re: bit-wise operators for bigint in Clojure

2020-05-28 Thread Alan Thompson
In Clojure, it is probably easiest to just use Java interop, eg:
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/BigInteger.html#setBit(int)
Alan


On Tue, May 26, 2020 at 9:39 AM Harmon Nine  wrote:

> Hello.
>
> I noticed a post about this from 2013, so doing a bump.
>
> The bit-wise operators appear to be supported for 'bigint' in
> ClojureScript, but not in Clojure.  Is support for these operations on
> 'bigint' in Clojure a future enhancement?
>
> Thanks :)
> -- Harmon
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/clojure/4b6e3f5e-c70c-404a-9348-8117a4b32db8%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/CAN67zA2sC%3D2TQYpWaZsfmPuGErTKmkY4buB2M3qPwRgJM%2Bpwxg%40mail.gmail.com.


bit-wise operators for bigint in Clojure

2020-05-26 Thread Harmon Nine
Hello.

I noticed a post about this from 2013, so doing a bump.

The bit-wise operators appear to be supported for 'bigint' in 
ClojureScript, but not in Clojure.  Is support for these operations on 
'bigint' in Clojure a future enhancement?

Thanks :)
-- Harmon

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/4b6e3f5e-c70c-404a-9348-8117a4b32db8%40googlegroups.com.