“f” after number

后端 未结 10 790
醉酒成梦
醉酒成梦 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 12:04

    Sometimes there is a difference.

    float f = 0.3; /* OK, throw away bits to convert 0.3 from double to float */
    assert ( f == 0.3 ); /* not OK, f is converted from float to double
       and the value of 0.3 depends on how many bits you use to represent it. */
    assert ( f == 0.3f ); /* OK, comparing two floats, although == is finicky. */
    

提交回复
热议问题