View previous topic :: View next topic |
Author |
Message |
Eddy71ua
Joined: 23 Sep 2009 Posts: 55 Location: Ukraine
|
Stupid question :lol: |
Posted: Thu Apr 14, 2011 8:15 am |
|
|
Several times in the listings I saw a record number: 5000000L What does the letter L after the number 5000000?
Code: |
frequency = (5000000L / (float)current_ccp_delta); |
I reread the instruction to the compiler and have not found an answer to this simple question. |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1907
|
|
Posted: Thu Apr 14, 2011 8:44 am |
|
|
Long. It forces the compiler to use 16 or 32 bit manipulations. ....Kind of like a forced cast I suppose. |
|
|
Eddy71ua
Joined: 23 Sep 2009 Posts: 55 Location: Ukraine
|
|
Posted: Thu Apr 14, 2011 12:43 pm |
|
|
Of course is long. 5000000 does not fit in int16. Why is it tells the compiler? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Thu Apr 14, 2011 3:00 pm |
|
|
Probably 'left in'.
Key is that if the same function is used with different numbers - perhaps 'defines', and the numbers drop below first 65536, and then below 256, the compiler will switch to using first 16bit, and then 8bit arithmetic. Using 'L' prevents this. It is part of standard C, and 'belt and braces', quite good practice if you want to be absolutely _sure_ that a drop back won't happen.
Best Wishes |
|
|
Eddy71ua
Joined: 23 Sep 2009 Posts: 55 Location: Ukraine
|
|
Posted: Thu Apr 14, 2011 3:02 pm |
|
|
Thank you very much for the detailed response |
|
|
|