Stan currently doesn’t have a function for converting reals
to ints
, but you can write one pretty simply:
int real_to_int(real x) {
int i = 1;
while(i < x) {
i += 1;
}
return i;
}
Note that this is a pretty basic implementation and will always round up:
real_to_int(25.0) = 25
real_to_int(25.1) = 26
So keep that in mind if you end up working with reals
that have decimals