Page 1 of 1

Big Numbers?

PostPosted: Thu Jul 01, 2010 2:58 pm
by _Gold_Fish
class Program
def main
print 2**30
print 2**31
print 2**32

returns
Code: Select all
1073741824
-2147483648
-2147483648


The first is correct, the second is the negative of the proper answer answer, and the third is totally wrong.

I know (think) this has to do with int32 limits. Which leads me to my question: is there a built in class(s) in Cobra for operating with large numbers (over uint64's limit)?

In another thread in this forum, someone suggested a C# library (BIGINT, I think), however it looks messy (things like needing extra parenthesis) and I'd rather use something native to Cobra.

Re: Big Numbers?

PostPosted: Thu Jul 01, 2010 6:22 pm
by Charles
We do not have a "BigDecimal" or "BigInteger" type at this time. Can you tell me what applications you had in mind that will exceed, say int64?

Re: Big Numbers?

PostPosted: Fri Jul 02, 2010 3:50 am
by _Gold_Fish
I've been messing around with some physics stuff in Cobra, and you can get pretty numbers pretty quickly. Also, ProjectEuler :D