Replacement for `fabs`, `fmax`, etc. for use with CGFloat on 64-bit iOS devices

前端 未结 1 1065
执念已碎
执念已碎 2021-02-20 06:10

Question

Consider layout code like this:

CGFloat descriptionHeight = // height of a paragraph of text with zero or more words;
CGFloat imageHeight = // h         


        
相关标签:
1条回答
  • 2021-02-20 06:20

    There is never any "data loss" incurred when converting a float into a double. That conversion is always exact.

    Your solutions 1 & 2 are entirely equivalent semantically, though (2) is more stylistically correct.

    Your solution 3 is formally not equivalent; it may incur extra conversions between float and double, which may make it slightly less efficient (but the actual result is identical).

    Basically, it doesn't matter, but use tgmath.

    0 讨论(0)
提交回复
热议问题