Arc Forumnew | comments | leaders | submitlogin
2 points by rocketnia 4708 days ago | link | parent

Yeah, I guess Rainbow doesn't bother with bignums. Jarc has exactly the same result, probably because they both use JVM longs. They both still let us use JVM bignums the long way though:

  ; This code will work on both Rainbow and Jarc.
  (when (errsafe jarc.Jarc.class) use!rainbow)
  
  (def big (x)
    (java-static-invoke "java.math.BigInteger" 'valueOf x))
  
  (def bigfact (x)
    (if (< x 0)  nil
        (< 0 x)  ((bigfact:- x 1) 'multiply big.x)
                 big.1))

  Rainbow:
  
  arc> (= foo bigfact.50)
  30414093201713378043612608166064768844377641568960512000000000000
  arc> type.foo
  java-object
  arc> foo!getClass
  class java.math.BigInteger
  
  
  Jarc:
  
  Jarc> (= foo bigfact.50)
  #java.math.BigInteger(743210128)
  Jarc> foo!toString
  "30414093201713378043612608166064768844377641568960512000000000000"
  Jarc> type.foo
  java.math.BigInteger
  Jarc> foo!getClass
  #class(java.math.BigInteger)


1 point by rocketnia 4708 days ago | link

Hmm, Semi-Arc does have bignums. ^_^

  arc> (= foo 1)
  1
  arc> (for i 1 50 (zap * foo i))
  nil
  arc> foo
  30414093201713378043612608166064768844377641568960512000000000000
  arc> type.foo
  int
  arc> (/ 1 foo)
  1/30414093201713378043612608166064768844377641568960512000000000000

-----