u32 vs int f32 vs float
u32 vs int f32 vs float
I'm not sure when i should use an int or when I should use a u32. I'm guessing u32 is Irrlicht's int, I could be wrong. If I use a value time I must make it an u32 for getTime() to work. but If I use abs from math.h I need to use a int. abs( int value );.. If I use a u32 it complains. I guess I coudl cast it? So I'm just wondering what is suggested here?
It's for portability. You can safely assume that a u32 is an unsigned 32 bit integer and can hold over 4 billion values; sizeof(u32) is always 4. The only thing you can assume about an int is that it is at least 16 bits, so it might be any size depending on the processor and compiler.
So when you port Irrlicht to run on your calculator, you just need to typedef the correct types in irrTypes.h and everything will work without problems... in theory. (why not try it?
)
So when you port Irrlicht to run on your calculator, you just need to typedef the correct types in irrTypes.h and everything will work without problems... in theory. (why not try it?
ahhhh, cool. Ok got it!!bitplane wrote:It's for portability. You can safely assume that a u32 is an unsigned 32 bit integer and can hold over 4 billion values; sizeof(u32) is always 4. The only thing you can assume about an int is that it is at least 16 bits, so it might be any size depending on the processor and compiler.
So when you port Irrlicht to run on your calculator, you just need to typedef the correct types in irrTypes.h and everything will work without problems... in theory. (why not try it?)
I read somewhere that INT_MIN had to be <= -32767, which would mean ints must be at least 16-bit. I haven't got my C++ reference book handy at the moment, but I found this on Google books.. Is that wrong?vitek wrote:It is actually perfectly legal for an int to be just one byte, provided that the size of a short is no more than one byte.bitplane wrote:The only thing you can assume about an int is that it is at least 16 bits
You are absolutely right. 5.2.4.2.1 Sizes of integer types in the C99 standard does say that INT_MIN <= -32767 and INT_MAX >= 32767, which would require it to be 16-bit.
Apparently I was remembering that a int could be no smaller than a short and applying that all the way up the heirarchy. Sorry about that.
Apparently I was remembering that a int could be no smaller than a short and applying that all the way up the heirarchy. Sorry about that.