Is there any accuracy lost when dividing a CGFloat by a NSTimeInterval?
I am trying to translate a NSTimeInterval to a UIView.frame.size.width and currently casting it to a float.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
An
NSTimeIntervalis a typedef for adouble, which is guaranteed to have at least as much precision as aCGFloat(CGFloatis defined as afloaton 32-bit systems and adoubleon 64-bit systems).So no, diving a
CGFloatby anNSTimeIntervalwill not lose any accuracy (compared to dividing it by anotherCGFloatthat is; floating-point math always has precision/accuracy worries).