I need to simulate some 62-bit circuitry. I seem to remember reading somewhere about a C++ facility that lets me define integers of my own length, but my googling efforts found nothing useful. Can someone point me in the right direction?
Thanks, Disch. I don't think they will either, plus it's my understanding that they're not very portable.
My original intention was to use 64-bit integers, but I'm not sure that's a good choice, either, since a value that would overflow a 62-bit field won't do the same to a 64-bit field.
I could swear that I read somewhere about defining integers of whatever length you wished...
CreativeMFS is probably thinking of __int8, __int16, etc. Those are non-standard compiler intrinsics built into Windows compilers, and they only work for sizes that the CPU natively handles (e.g. 8, 16, 32, and 64 on x86), not any length the programmer wants.
I'm fairly sure Disch's suggestion only works if the data type is large enough to contain all those bits, and an int probably isn't.
I'd suggest either an integer of guaranteed size, such as boost::uint64_t, a simple array of chars (how many bits each char will hold is not really important), or an std::vector<bool>. Which is best depends on what OP plans to do with the bits.
Thanks for the suggestions, guys. After more looking, I still can't find anything, so maybe I just dreamt it up. I think I'll just use the int64_t type that the compiler provides. That looks good for gcc and VS.