if i have a bitset<16> bits(*iter)
and a my short
how i can assign this bist to my short?
short myShort = ??bits??
It's possible to convert a bitset<16> to short?
You really should use an unsigned short, to avoid language quirks on the high bit.
unsigned short myShort = (unsigned short)bits.to_ulong();
I'd use the to_ulong
method for this, and cast the result (since you know that only the lowest 16 bit will be used):
short myShort = static_cast<short>( bits.to_ulong() );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With