Go Down

Topic: Another pair of eyes needed (Read 412 times) previous topic - next topic

Nick Gammon

Well spotted, AWOL.

http://www.gammon.com.au/forum/?id=12146
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

AWOL

Quote
Even so, I think there's something about what you said.  All the values I used during testing were less than 32767.  An unsigned long in this environment is 32 bits, which far exceeds those values, but there is something suspicious going on here. I just wish I knew what it is.

The "it" is 16 bit signed arithmetic.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Nick Gammon


Code: [Select]
unsigned long countdown = 0;

Even so, I think there's something about what you said.  All the values I used during testing were less than 32767.  An unsigned long in this environment is 32 bits, which far exceeds those values, but there is something suspicious going on here. I just wish I knew what it is.


Yes well if you read my link you will see that assigning to unsigned long (or testing against it) does not force the RHS to be unsigned long.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Barry914

#18
Sep 26, 2014, 07:49 am Last Edit: Sep 26, 2014, 08:11 am by Barry914 Reason: 1
Well, that was an eye opener AWOL & Nick.  I learned three things:

1.  I now know how the compiler treats literals.
2. If i am going to ask a question, I probably should pay close attention to the answer.  
3. Stubbornness is not a positive attribute.

I appreciate the help.  Thank you very much.

Docedison

--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Go Up