Decimal128
@objc(RealmSwiftDecimal128)
public final class Decimal128 : RLMDecimal128, Decodable, @unchecked Sendable
extension Decimal128: BSON
extension Decimal128: Encodable
extension Decimal128: ExpressibleByIntegerLiteral
extension Decimal128: ExpressibleByFloatLiteral
extension Decimal128: ExpressibleByStringLiteral
extension Decimal128: Comparable
extension Decimal128: Numeric
extension Decimal128: _PersistableInsideOptional, _DefaultConstructible
extension Decimal128: _QueryNumeric
extension Decimal128: _RealmCollectionValueInsideOptional
extension Decimal128: MinMaxType
extension Decimal128: AddableType
extension Decimal128: SortableType
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
Swift
public override required init() -
Converts the given value to a Decimal128.
The following types can be converted to Decimal128:
- Int (of any size)
- Float
- Double
- String
- NSNumber
- Decimal
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
Swift
public override required init(value: Any)Parameters
valueThe value to convert to a Decimal128.
-
Converts the given number to a Decimal128.
This initializer cannot fail and is never lossy.
Declaration
Swift
public override required init(number: NSNumber)Parameters
numberThe number to convert to a Decimal128.
-
Parse the given string as a Decimal128.
This initializer never throws and is marked as
throwsonly because removing it is a breaking change. Strings which cannot be parsed as a Decimal128 return a value whereisNaNistrue.Declaration
Swift
public override required init(string: String) throwsParameters
stringThe string to parse.
-
Creates a new Decimal128 by decoding from the given decoder.
This initializer throws an error if the decoder is invalid or does not decode to a value which can be converted to Decimal128.
Declaration
Swift
public required init(from decoder: Decoder) throwsParameters
decoderThe decoder to read data from.
-
The mininum value for Decimal128
Declaration
Swift
public static var min: Decimal128 { get } -
The maximum value for Decimal128
Declaration
Swift
public static var max: Decimal128 { get } -
Encodes this Decimal128 to the given encoder.
This function throws an error if the given encoder is unable to encode a string.
Declaration
Swift
public func encode(to encoder: Encoder) throwsParameters
encoderThe encoder to write data to.
-
Creates a new Decimal128 from the given integer literal.
Declaration
Swift
public convenience init(integerLiteral value: Int64) -
Creates a new Decimal128 from the given float literal.
Declaration
Swift
public convenience init(floatLiteral value: Double) -
Creates a new Decimal128 from the given string literal.
Aborts if the string cannot be parsed as a Decimal128.
Declaration
Swift
public convenience init(stringLiteral value: String) -
Returns a Boolean value indicating whether two decimal128 values are equal.
Declaration
Swift
public static func == (lhs: Decimal128, rhs: Decimal128) -> BoolParameters
lhsA Decimal128 value to compare.
rhsAnother Decimal128 value to compare.
-
Returns a Boolean value indicating whether the decimal128 value of the first argument is less than that of the second argument.
Declaration
Swift
public static func < (lhs: Decimal128, rhs: Decimal128) -> BoolParameters
lhsA Decimal128 value to compare.
rhsAnother Decimal128 value to compare.
-
Returns a Boolean value indicating whether the decimal128 value of the first argument is less than or equal to that of the second argument.
Declaration
Swift
public static func <= (lhs: Decimal128, rhs: Decimal128) -> BoolParameters
lhsA Decimal128 value to compare.
rhsAnother Decimal128 value to compare.
-
Returns a Boolean value indicating whether the decimal128 value of the first argument is greater than or equal to that of the second argument.
Declaration
Swift
public static func >= (lhs: Decimal128, rhs: Decimal128) -> BoolParameters
lhsA Decimal128 value to compare.
rhsAnother Decimal128 value to compare.
-
Returns a Boolean value indicating whether the decimal128 value of the first argument is greater than that of the second argument.
Declaration
Swift
public static func > (lhs: Decimal128, rhs: Decimal128) -> BoolParameters
lhsA Decimal128 value to compare.
rhsAnother Decimal128 value to compare.
-
Creates a new instance from the given integer, if it can be represented exactly.
If the value passed as
sourceis not representable exactly, the result isnil. In the following example, the constantxis successfully created from a value of100, while the attempt to initialize the constantyfrom1_000fails because theInt8type can represent127at maximum:Declaration
Swift
public convenience init?<T>(exactly source: T) where T : BinaryIntegerParameters
sourceA value to convert to this type of integer.
-
A type that can represent the absolute value of Decimal128
Declaration
Swift
public typealias Magnitude = Decimal128 -
The magnitude of this Decimal128.
Declaration
Swift
public var magnitude: Magnitude { get } -
Adds two decimal128 values and produces their sum.
Declaration
Swift
public static func + (lhs: Decimal128, rhs: Decimal128) -> Decimal128Parameters
lhsThe first Decimal128 value to add.
rhsThe second Decimal128 value to add.
-
Subtracts one Decimal128 value from another and produces their difference.
Declaration
Swift
public static func - (lhs: Decimal128, rhs: Decimal128) -> Decimal128Parameters
lhsA Decimal128 value.
rhsThe Decimal128 value to subtract from
lhs. -
Multiplies two Decimal128 values and produces their product.
Declaration
Swift
public static func * (lhs: Decimal128, rhs: Decimal128) -> Decimal128Parameters
lhsThe first value to multiply.
rhsThe second value to multiply.
-
Multiplies two values and stores the result in the left-hand-side variable.
Declaration
Swift
public static func *= (lhs: inout Decimal128, rhs: Decimal128)Parameters
lhsThe first value to multiply.
rhsThe second value to multiply.
-
Returns the quotient of dividing the first Decimal128 value by the second.
Declaration
Swift
public static func / (lhs: Decimal128, rhs: Decimal128) -> Decimal128Parameters
lhsThe Decimal128 value to divide.
rhsThe Decimal128 value to divide
lhsby.rhsmust not be zero. -
A type that represents the distance between two values.
Declaration
Swift
public typealias Stride = Decimal128 -
Returns the distance from this Decimal128 to the given value, expressed as a stride.
Declaration
Swift
public func distance(to other: Decimal128) -> Decimal128Parameters
otherThe Decimal128 value to calculate the distance to.
Return Value
The distance from this value to
other. -
Returns a Decimal128 that is offset the specified distance from this value.
Use the
advanced(by:)method in generic code to offset a value by a specified distance. If you’re working directly with numeric values, use the addition operator (+) instead of this method.Declaration
Swift
public func advanced(by n: Decimal128) -> Decimal128Parameters
nThe distance to advance this Decimal128.
Return Value
A Decimal128 that is offset from this value by
n. -
trueifselfis a signaling NaN,falseotherwise.Declaration
Swift
public var isSignaling: Bool { get } -
trueifselfis a signaling NaN,falseotherwise.Declaration
Swift
public var isSignalingNaN: Bool { get }
-
Undocumented
Declaration
Swift
public static var _rlmType: PropertyType { get }
-
Undocumented
Declaration
Swift
public typealias PersistedType = Decimal128 -
Undocumented
Declaration
Swift
@inlinable public static func _rlmGetProperty(_ obj: ObjectBase, _ key: PropertyKey) -> Decimal128 -
Undocumented
Declaration
Swift
@inlinable public static func _rlmGetPropertyOptional(_ obj: ObjectBase, _ key: PropertyKey) -> Decimal128? -
Undocumented
Declaration
Swift
@inlinable public static func _rlmSetProperty(_ obj: ObjectBase, _ key: PropertyKey, _ value: Decimal128) -
Undocumented
Declaration
Swift
public static func _rlmFromObjc(_ value: Any) -> Decimal128? -
Undocumented
Declaration
Swift
public var _rlmObjcValue: Any { get }
View on GitHub
Install in Dash