Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Jan Waclawek
01/17/13 01:30
Modified:
  01/17/13 01:31

Read: 653 times
Bratislava
Slovakia


 
Msg Score: +1
 +1 Good Answer/Helpful
#189212 - when implicit type shall be overriden
Responding to: Aamir Ali's previous message
Aamir Ali said:

When should we add suffix f for float & ul for long.
When you write a "numbers" (constants) in a C program, the compiler not only converts it into its binary form, but also "gives" it a type according to a set of rules. Basically, without the suffix, if it is a decimal number and there is no decimal point, it is int; if there is decimal point, it is double (for more details see C99 chapter 6.4.4).

Suffixes override this default behaviour and through them you can give a type to the constant explicitly. This may be needed because of the rules how calculations are performed, for example the 1 << 23 expression below in a compiler where int is 16 bits results in 0 (as the constant 1 is implicitly int thus only 16 bits and the shift shifts it out completely).

JW

List of 2 messages in thread
TopicAuthorDate
When add f,ul in suffix of number in c      Aamir ALi      01/16/13 23:51      
   when implicit type shall be overriden        Jan Waclawek      01/17/13 01:30      

Back to Subject List