Does C++ have a 6 byte Number Data Type??.
I could not find one so I wrote my own class object for it
floats are 4
doubles are 8
l
Does C++ have a 6 byte Number Data Type??.
I could not find one so I wrote my own class object for it
floats are 4
doubles are 8
l
no, it doesnt. All it's got are chars, ints, floats, and longs.
Well depending on your compiler (which you don't mention), you could have
long long int foo;
__int64_t bar;
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I just posted on another thread about bitfields, which you might be able to use. You can build a struct that aligns a specific number of bits for a data type.
it might get a little cumbersome to use, but I'm sure it wouldn't be too much of a hassle.Code:struct Int36 { int num : 36; };
There are many ways you can accomplish it. You could do like skorman said with a little bit of inconvenience (and I mean little). I've used bitfields for embedded programming a lot. Worked like a charm for our robot controller.
You could go with Salem's method, if you don't care about wasting a little bit of space, which I again, I emphasise little
You could even make a C++ class and overload all the operators if you want to go all out
You can get this bahavior by using std::bitset
Last edited by okinrus; 07-08-2004 at 05:34 PM.