Tiny float question


#1

On page 133 why is the CGSizeMake(4,3) not CGSizeMake(4.0, 3.0)
and then conversely inside the CGContextSetShadowWithColor(ctx, offset, 2.0, color) not …offset, 2, color)?

Just curious …both work both ways in this case - they are both offsets really.

My ancient K&R C book says that with division 5/9 and 5.0/9.0 aren’t the same. That is still applicable here right?

Thanks,
-Dan


#2

They, 4 & 3, will be typecast to CGFloat because CGSizeMake is declared as CGSize CGSizeMake (CGFloat width, CGFloat height); CGFloat in term is …

Although they will be typecast, it is better to write them as floating-point literals 4.0f and 3.0f.


#3

Thanks - I do like the way XCode tells you as you type that it IS a float! It just seemed like there’s a convention being followed in the book and I wondered what it was.