Just wondering if its correct to compare u8 and u32
u8 uint8;
u32 uint32;
if (uint8 <= uint32) {}
and so on
u8 and u32
-
hybrid
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Re: u8 and u32
Yes, that should work. Just avoid mixing s-types and u-types
Re: u8 and u32
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.
-
hybrid
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Re: u8 and u32
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.
