1) define big NSInteger
2) cast to float
3) log float
4) turns into slightly smaller number every time???
NSInteger val = 485935336;
float val_float = (float)val;
NSLog(@"%f", val_float); //logs 485935328, not 485935336
Any clue why?
1) define big NSInteger
2) cast to float
3) log float
4) turns into slightly smaller number every time???
NSInteger val = 485935336;
float val_float = (float)val;
NSLog(@"%f", val_float); //logs 485935328, not 485935336
Any clue why?
Copyright © 2021 Jogjafile Inc.
Any idea why? Of course. float has about six digits of precision. double has 15 digits precision, which is why you should always use double unless you can give a good reason why not. You will get the same problem, but only when the numbers are a lot bigger.