[Ovmsdev] SIM808/SIM908 GPS accuracy

Edward Cheeseman cheesemanedward at gmail.com
Wed Feb 8 07:20:22 HKT 2017

> On 8/02/2017, at 11:50 AM, Tom Saxton <tom at idleloop.com> wrote:
> You're right, 1 << 7 doesn't send it off the end. That's my mistake.
> 00000001 << 7 is 10000000, which is -128 when treated as a signed byte and +128 when treated as unsigned. In this case, the operation should be treated as a signed int, so it should have been adding -128 (subtracting 128) instead of adding the 128 you intended. What actually happened would depend on the rest of the expression.

Given it was a rounding value only, subtraction instead of addition would have a result of one less which is what I saw. The other rounding I used (1<<17) was sure to overflow 8bit!

>  My favorite is JdFromYMD() which took just one cast, the "L" on 1461, to get that whole giant magic expression to evaluate correctly.

Yeah I’ve skimmed past the Date stuff and thought I’m glad I’m not having to work out how that works. Now that I am becoming aware of the extent of casting required, this function seems all the more magical.

More information about the OvmsDev mailing list