integer size limit?

webb's icon

Is there a size limit for integers? It appears to be 32 bits but I sure hope there's a way around it...

Peter Castine's icon

32 bits is what you get.

Ways around it? (1) floats (with all the issues they bring) and (2) use pairs of ints and treat them as 64-bit values--which means building your own abstractions (or externals) for whatever arithmetic you want to do.

Christopher Dobrian's icon

3) Java, using the BigInteger class.

webb's icon

Thanks I think I'll go with the Max external route.

Roman Thilenius's icon

i´d say int is 24 bits, but peter might explain now why it is 32. ^^

MIB's icon
Max Patch
Copy patch and select New From Clipboard in Max.

why would you think it's 24 bits? a simple patch confirms what int really is... unless I'm once again not getting it ;)

Roman Thilenius's icon

i dont know why. i always have that in my mind, probably because it does not really matter for int. :)

Peter Castine's icon

Roman may be thinking of the precision in floating point, which effectively has a 24-bit mantissa.

32-bit integers have 32-bit precision because, errmmm, they have 32 bits. Anybody else want to explain this without resorting to a tautology?

Chris' suggestion about the Java BigInteger class is a good idea. But if you want to have the data passed around multiple objects, for whatever reason, you'll still have to develop some strategy based around pairs of 32-bit values. Alternately, one could pass pointers disguised as ints through patch cords, but that probably has even more headaches.

Roman Thilenius's icon

i really thought LONG is 0F FF ... and i am not even able to explain why.

probably because in maxmsp the highest possible value in float is the
same number as it is in int ...