[Ovmsdev] SIM808/SIM908 GPS accuracy
cheesemanedward at gmail.com
Wed Feb 8 05:22:17 HKT 2017
I was about to complain that 128 fits into 8bits - but of course it doesn’t fit into a signed 8bit int. My bad.
> On 8/02/2017, at 10:14 AM, Tom Saxton <tom at idleloop.com> wrote:
> For the C18 compiler, an int is 8 bits. In C, all math is done in ints unless forced to a larger type by operands or casting. When you do (1<<7) in an 8-bit int, you shift the bit off the end of the int and get zero. The compiler didn't ignore your constant, it did exactly what it's supposed to do.
> You can fix it with a cast, like:
> ((long)1 << 7) or (1L << 7)
More information about the OvmsDev