Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <limits.h>
00020
00021 #include "rqt_multiplot/BitOperations.h"
00022
00023 namespace rqt_multiplot {
00024
00025
00026
00027
00028
00029 unsigned int BitOperations::revertInt(unsigned int val) {
00030 unsigned int reverse = val;
00031 unsigned int shift = sizeof(unsigned int)*CHAR_BIT-1;
00032
00033 for (val >>= 1; val; val >>= 1) {
00034 reverse <<= 1;
00035 reverse |= val & 1;
00036 --shift;
00037 }
00038 reverse <<= shift;
00039
00040 return reverse;
00041 }
00042
00043 unsigned short BitOperations::revertShort(unsigned short val) {
00044 unsigned short reverse = val;
00045 unsigned short shift = sizeof(unsigned short)*CHAR_BIT-1;
00046
00047 for (val >>= 1; val; val >>= 1) {
00048 reverse <<= 1;
00049 reverse |= val & 1;
00050 --shift;
00051 }
00052 reverse <<= shift;
00053
00054 return reverse;
00055 }
00056
00057 unsigned char BitOperations::revertByte(unsigned char val) {
00058 unsigned char reverse = val;
00059 unsigned char shift = sizeof(unsigned char)*CHAR_BIT-1;
00060
00061 for (val >>= 1; val; val >>= 1) {
00062 reverse <<= 1;
00063 reverse |= val & 1;
00064 --shift;
00065 }
00066 reverse <<= shift;
00067
00068 return reverse;
00069 }
00070
00071 };