« Return to Thread: When integers go bad

Re: When integers go bad

by Tim Walters :: Rate this Message:

Reply to Author | View in Thread

I like Ruby's solution, which is that integers get promoted to BigNums
transparently as needed:

irb(main):010:0> a = 1000000000
=> 1000000000
irb(main):013:0> a.class
=> Fixnum
irb(main):011:0> b = 1000
=> 1000
irb(main):014:0> b.class
=> Fixnum
irb(main):015:0> c = a * b
=> 1000000000000
irb(main):016:0> c.class
=> Bignum
irb(main):017:0> c * c
=> 1000000000000000000000000

I have no idea how hard this would be to implement, or what the
performance implications would be. But it's nifty.

--
Tim Walters | http://doubtfulpalace.com


_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

 « Return to Thread: When integers go bad