RLMDecimal128

Objective-C

@interface RLMDecimal128 : NSObject <NSCopying>

Swift

class RLMDecimal128 : NSObject, NSCopying

A 128-bit IEEE 754-2008 decimal floating point number.

This type is similar to Swift’s built-in Decimal type, but allocates bits differently, resulting in a different representable range. (NS)Decimal stores a significand of up to 38 digits long and an exponent from -128 to 127, while this type stores up to 34 digits of significand and an exponent from -6143 to 6144.

  • Creates a new zero-initialized decimal128.

    Declaration

    Objective-C

    - (nonnull instancetype)init;

    Swift

    init()
  • Converts the given value to a RLMDecimal128.

    The following types can be converted to RLMDecimal128:

    • NSNumber
    • NSString
    • NSDecimalNumber

    Passing a value with a type not in this list is a fatal error. Passing a string which cannot be parsed as a valid Decimal128 is a fatal error.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithValue:(nonnull id)value;

    Swift

    init(value: Any)
  • Converts the given number to a RLMDecimal128.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithNumber:(nonnull NSNumber *)number;

    Swift

    init(number: NSNumber)
  • Parses the given string to a RLMDecimal128.

    Returns a decimal where isNaN is YES if the string cannot be parsed as a decimal. error is never set and this will never actually return nil.

    Declaration

    Objective-C

    - (nullable instancetype)initWithString:(nonnull NSString *)string
                                      error:(NSError *_Nullable *_Nullable)error;

    Swift

    init(string: String) throws
  • Converts the given number to a RLMDecimal128.

    Declaration

    Objective-C

    + (nonnull instancetype)decimalWithNumber:(nonnull NSNumber *)number;
  • The minimum value for RLMDecimal128.

    Declaration

    Objective-C

    @property (class, copy, readonly) NS_REFINED_FOR_SWIFT RLMDecimal128 *minimumDecimalNumber;
  • The maximum value for RLMDecimal128.

    Declaration

    Objective-C

    @property (class, copy, readonly) NS_REFINED_FOR_SWIFT RLMDecimal128 *maximumDecimalNumber;
  • Convert this value to a double. This is a lossy conversion.

    Declaration

    Objective-C

    @property (nonatomic, readonly) double doubleValue;

    Swift

    var doubleValue: Double { get }
  • Convert this value to a NSDecimal. This may be a lossy conversion.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSDecimal decimalValue;

    Swift

    var decimalValue: Decimal { get }
  • Convert this value to a string.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSString *_Nonnull stringValue;

    Swift

    var stringValue: String { get }
  • Gets if this Decimal128 represents a NaN value.

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL isNaN;

    Swift

    var isNaN: Bool { get }
  • The magnitude of this RLMDecimal128.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NS_REFINED_FOR_SWIFT RLMDecimal128 *magnitude;
  • Replaces this RLMDecimal128 value with its additive inverse.

    Declaration

    Objective-C

    - (void)negate;

    Swift

    func negate()
  • Adds the right hand side to the current value and returns the result.

    Declaration

    Objective-C

    - (nonnull RLMDecimal128 *)decimalNumberByAdding:
        (nonnull RLMDecimal128 *)decimalNumber;

    Swift

    func decimalNumber(byAdding decimalNumber: RLMDecimal128) -> RLMDecimal128
  • Divides the right hand side to the current value and returns the result.

    Declaration

    Objective-C

    - (nonnull RLMDecimal128 *)decimalNumberByDividingBy:
        (nonnull RLMDecimal128 *)decimalNumber;

    Swift

    func decimalNumberByDividing(by decimalNumber: RLMDecimal128) -> RLMDecimal128
  • Subtracts the right hand side to the current value and returns the result.

    Declaration

    Objective-C

    - (nonnull RLMDecimal128 *)decimalNumberBySubtracting:
        (nonnull RLMDecimal128 *)decimalNumber;

    Swift

    func decimalNumber(bySubtracting decimalNumber: RLMDecimal128) -> RLMDecimal128
  • Multiply the right hand side to the current value and returns the result.

    Declaration

    Objective-C

    - (nonnull RLMDecimal128 *)decimalNumberByMultiplyingBy:
        (nonnull RLMDecimal128 *)decimalNumber;

    Swift

    func decimalNumberByMultiplying(by decimalNumber: RLMDecimal128) -> RLMDecimal128
  • Comparision operator to check if the right hand side is greater than the current value.

    Declaration

    Objective-C

    - (BOOL)isGreaterThan:(nullable RLMDecimal128 *)decimalNumber;

    Swift

    func isGreaterThan(_ decimalNumber: RLMDecimal128?) -> Bool
  • Comparision operator to check if the right hand side is greater than or equal to the current value.

    Declaration

    Objective-C

    - (BOOL)isGreaterThanOrEqualTo:(nullable RLMDecimal128 *)decimalNumber;

    Swift

    func isGreaterThanOrEqual(to decimalNumber: RLMDecimal128?) -> Bool
  • Comparision operator to check if the right hand side is less than the current value.

    Declaration

    Objective-C

    - (BOOL)isLessThan:(nullable RLMDecimal128 *)decimalNumber;

    Swift

    func isLessThan(_ decimalNumber: RLMDecimal128?) -> Bool
  • Comparision operator to check if the right hand side is less than or equal to the current value.

    Declaration

    Objective-C

    - (BOOL)isLessThanOrEqualTo:(nullable RLMDecimal128 *)decimalNumber;

    Swift

    func isLessThanOrEqual(to decimalNumber: RLMDecimal128?) -> Bool