session-ios/Signal/src/util/NumberUtil.h
2017-12-05 11:19:11 -05:00

42 lines
1.1 KiB
Objective-C

//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
@interface NumberUtil : NSObject
+ (int16_t)congruentDifferenceMod2ToThe16From:(uint16_t)s1 to:(uint16_t)s2;
+ (int8_t)signOfInt32:(int32_t)value;
+ (int8_t)signOfDouble:(double)value;
+ (NSUInteger)largestIntegerThatIsAtMost:(NSUInteger)value andIsAMultipleOf:(NSUInteger)multiple;
+ (NSUInteger)smallestIntegerThatIsAtLeast:(NSUInteger)value andIsAMultipleOf:(NSUInteger)multiple;
+ (double)clamp:(double)value toMin:(double)min andMax:(double)max;
+ (NSUInteger)from:(NSUInteger)value subtractWithSaturationAtZero:(NSUInteger)minusDelta;
+ (uint8_t)uint8FromLowUInt4:(uint8_t)low4UInt4 andHighUInt4:(uint8_t)highUInt4;
+ (uint8_t)lowUInt4OfUint8:(uint8_t)value;
+ (uint8_t)highUInt4OfUint8:(uint8_t)value;
+ (NSUInteger)assertConvertIntToNSUInteger:(int)value;
+ (NSInteger)assertConvertUnsignedIntToNSInteger:(unsigned int)value;
+ (int)assertConvertNSUIntegerToInt:(NSUInteger)value;
@end
@interface NSNumber (NumberUtil)
- (bool)hasUnsignedIntegerValue;
- (bool)hasUnsignedLongLongValue;
- (bool)hasLongLongValue;
@end