Hello,
I realy don't understand these operators << and >>
In this example what is the value of offset ? 10 right ?
What's the difference with offset++
#define ADC_BITS 10
#define ADC_COUNTS (1<<ADC_BITS)
offset = ADC_COUNTS>>1;
Thanks
Here is a simple way to think about it:
a << b multiplies value a by the number 2, b times
a >> b divides value a by the number 2, b times
so:
#define ADC_COUNTS (1<<10)
offset = ADC_COUNTS>>1;
means:
offset = (1<<10) >> 1;
means :
offset = (1*2*2*2*2*2*2*2*2*2*2) /2;
means:
offset = 512
512 is 1000000000 in binary , having exactly 9 zeroes
Last edited on
Ok clear.
Manipulate decimals is easier to understand, for me at least.
thanks