How to get half of the last binary number
For example if we have 101010
First half is 101 which you get by multiplying 101010 * 10 ^-3
now how do you get the second half (010) ??
Just subtract the first half from the whole thing, remembering to add trailing zeroes:
101010 * 10^(-3) = 101
101010 - 101000 = 010
convert it to a string is what I do. I templated the conversion function, so it only has to be written once (instead of written for every single data type conversion needed).
template<class type1, class type2>
type2 conv(const type1& t1)
next, you can just cut up the string the way you wish, and convert it back.
Topic archived. No new replies allowed.