Created
January 11, 2014 03:36
-
-
Save cdzombak/8366662 to your computer and use it in GitHub Desktop.
float comparisons in Objective-C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
int main(int argc, char *argv[]) { | |
@autoreleasepool { | |
NSLog(@"0.1: %@", 0.1f == 0.1 ? @"exactly equal" : @"not exactly equal"); | |
NSLog(@"0.5: %@", 0.5f == 0.5 ? @"exactly equal" : @"not exactly equal"); | |
NSLog(@"1.0: %@", 1.0f == 1.0 ? @"exactly equal" : @"not exactly equal"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2013-10-24 10:08:14.285 Untitled[49887:507] 0.1: not exactly equal | |
2013-10-24 10:08:14.301 Untitled[49887:507] 0.5: exactly equal | |
2013-10-24 10:08:14.302 Untitled[49887:507] 1.0: exactly equal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment