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

Back to Subject List

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

Read: times


 
Msg Score: +1
 +1 Good Answer/Helpful
#189212 - when implicit type shall be overriden
Responding to: ???'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            01/01/70 00:00      
   when implicit type shall be overriden            01/01/70 00:00      

Back to Subject List