Noob question about 32-bit ints

I was reading through the users manual and came across this.

Stan uses 32-bit (4-byte) integers for all of its integer representations. The maximum
value that can be represented as an integer is 2^31 βˆ’ 1

so 2^31 -1 is about 2.9 billion. So, if your outcome variable was company dollars that were over 2 billion dollars then you could not use Stan?

This does not seem right.

With amounts like that just use doubles.

2 Likes

Thats what I figured. I just wanted to make sure that the limit was that low.

Yeah this is an issue everywhere, for us it’s been difficult to deal with in generated quantities where sometimes an RNG can produce a number too large to represent and then throw/crash the model. I think we did something about that. I think R only recently went to 64-bit integers everywhere (?) but yeah, main question to ask is whether you really need exact numbers.

We are hopefully going to move to 64-bit ints soon

but yeah, you should just use real numbers for dollar amounts.

2 Likes