I am on macOS, objective-c. Not swift, not iOS.
For passing a float i temporarily need to make it an object at a certain point:
NSNumber* floatNumber = @.5;
// Other stuff ...
float myFloat = [floatNumber floatValue]; // --> (float) 0.5
However, doing the same than above with
NSNumber* floatNumber = @.4;
// Other stuff ...
float myFloat = [floatNumber floatValue]; // --> (float) 0.400000006
This breaks the rest as i require the same float value 0.4
I already tried rounding
floorf([floatNumber floatValue] *100)/100; // --> (float) 0.400000006
Can someone explain this behaviour and tell me how to solve it