u8 and u32

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
VeTaL
Posts: 14
Joined: Mon Feb 21, 2011 8:39 am

u8 and u32

Post by VeTaL »

Just wondering if its correct to compare u8 and u32

u8 uint8;
u32 uint32;

if (uint8 <= uint32) {}

and so on
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: u8 and u32

Post by hybrid »

Yes, that should work. Just avoid mixing s-types and u-types
VeTaL
Posts: 14
Joined: Mon Feb 21, 2011 8:39 am

Re: u8 and u32

Post by VeTaL »

Thanks for fast answer.
Brainsaw
Posts: 1242
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Re: u8 and u32

Post by Brainsaw »

As there are warnings sometimes (at least when you compare u32 to f32) I do now prefer to do explicit casts when mixing datatypes, but it works without that as well.
Image
Dustbin::Games on the web: https://www.dustbin-online.de/
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: u8 and u32

Post by hybrid »

Well, you can certainly have problems with large numbers when comparing unsigned (or even signed) and floats. Just because the precision won't be good enough for them. You have only 23bit to represent the integer part. But using the same base type will have no such problems, as all smaller types can be expanded to 32bit without precision loss.
Post Reply