Anybody got any ideas about how I could implement 24 bit integer types? For example, with some compilers I've seen things like:-
typedef long long int Int64;
typedef unsigned long long int UInt64;
which are used for 64 bit types, but I want 24 bit types (3 bytes). I'd want to be able to do normal maths with them (plus, minus, multiply, divide etc) and assign values such as:-
UInt32 x = 24117248; // 0x1700000 (this overflows a 24 bit Uint)
UInt24 y = x; // result would equal 7340032 (0x700000) which is within range.
[Edit]
Ideally, they should also be capable of being cast to any of the other integer types - e.g.
Code:Int32 SomeFuncThatRequiresA16BitInt ( Int16 n )
{
return (n * 65536);
}
Int24 x = 29;
Int32 y = SomeFuncThatRequiresA16BitInt ((Int16) x );
