Reputation:
It's probably not very consequential, but I want to make sure I'm doing this right.
Say I have a long long
or an int
, if I want to do NSLog(@"%f", theirQuotient)
, should I cast each number a float
, or a CGFloat
or a double
?
Upvotes: 0
Views: 68
Reputation: 53000
All your choices are valid and which floating point type you use in general depends on your needs.
However in your particular example, passing the value as an argument to a variadic function (NSLog
) then choose double
- in (Objective-)C float
values are promoted to double
when passed as one of a variadic function additional parameters so you might as well pass a double
.
To understand more look up arithmetic conversions and promotions in C - this is basic stuff you should understand if doing any arithmetic.
Upvotes: 1