Skip to content

Commit

Permalink
F53OSCMessage: set number formatter rounding mode to “half up”
Browse files Browse the repository at this point in the history
- changing from the default `NSNumberFormatter` rounding mode of “half even”
  • Loading branch information
balord committed Feb 17, 2024
1 parent e3835ec commit dfdd253
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions Sources/F53OSC/F53OSCMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ + (void) initialize
NUMBER_FORMATTER = [[NSNumberFormatter alloc] init];
NUMBER_FORMATTER.allowsFloats = YES;
NUMBER_FORMATTER.locale = [NSLocale autoupdatingCurrentLocale];
NUMBER_FORMATTER.roundingMode = NSNumberFormatterRoundHalfUp;
}
}

Expand Down
1 change: 1 addition & 0 deletions Tests/F53OSCTests/F53OSCMessageTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ - (nullable id) oscMessageArgumentFromString:(NSString *)qsc typeTag:(NSString *
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setLocale:[NSLocale currentLocale]];
[formatter setAllowsFloats:YES];
[formatter setRoundingMode:NSNumberFormatterRoundHalfUp];

arg = [formatter numberFromString:qsc]; // 'i' or 'f'
}
Expand Down

0 comments on commit dfdd253

Please sign in to comment.