Pages: 1 [2]   Go Down
Author Topic: Another pair of eyes needed  (Read 272 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Melbourne, Australia
Offline Offline
Brattain Member
*****
Karma: 511
Posts: 19323
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well spotted, AWOL.

http://www.gammon.com.au/forum/?id=12146
Logged

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

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26626
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

Global Moderator
Melbourne, Australia
Offline Offline
Brattain Member
*****
Karma: 511
Posts: 19323
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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.
Logged

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

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Metro NYC
Offline Offline
Newbie
*
Karma: 1
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: September 26, 2014, 01:11:31 am by Barry914 » Logged

itshardtoputspacesbetweenthewordswithouttheuseofyourthumbs

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 48
Posts: 2935
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

+1 All... Great lesson

Doc
Logged

--> 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

Pages: 1 [2]   Go Up
Jump to: