“f” after number

后端 未结 10 770
醉酒成梦
醉酒成梦 2020-11-27 11:02

What does the f after the numbers indicate? Is this from C or Objective-C? Is there any difference in not adding this to a constant number?

CGRec         


        
10条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-27 11:41

    It tells the computer that this is a floating point number (I assume you are talking about c/c++ here). If there is no f after the number, it is considered a double or an integer (depending on if there is a decimal or not).

    3.0f -> float
    3.0 -> double
    3 -> integer
    

提交回复
热议问题