Maybe this is a dumb question, but I really can’t get it. For some reason float values in my program get rounded up during the assignment statement.
Here is the code:
Float64 time,test;
for( Shot *sh in _arrayOfShots)
{
time = sh.bFrameTime;
// right here time variable gets value rounded up to 2 decimal places
// for example: if sh.bFrameTime = 81.919998 => time = 81.92
NSNumber *num = [NSNumber numberWithFloat:time];
test = [num floatValue];
[edgeTime addObject:num];
}
// this is my Shot object structure
@interface Shot : NSObject
{
int bFrame;
int eFrame;
Float64 bFrameTime;
}
If anyone knows how to deal with this, please give me hint!
Thank you!
is not “rounded up to two decimal places”. The difference in the two is 0.000002, a change in magnitude of 0.0000000244, or about 8 decimal places. If your source value is single-precision float then it only has 7 decimal places of accuracy. (But you didn’t show the declaration of that so we can’t tell.)
The difference could also have to do with how you displayed the two values, as NSLog does a modicum of rounding.