# DecimalValue

``open class DecimalValue: DataValue``

DataValue subclass that wraps a `value` of type `decimal`.

• ``` zero ```

Wrapped zero value.

#### Declaration

Swift

``public static let zero: DecimalValue = DecimalValue.of(DecimalFunction.fromInt((0 as Int)))``
• ``` compare(_:_:) ```

Compare two wrapped values for ordering.

#### Declaration

Swift

``open class func compare(_ left: DecimalValue, _ right: DecimalValue) -> Int``

#### Parameters

 ``` left ``` First object for comparison. ``` right ``` Second object for comparison.

#### Return Value

-1 if `left.value < right.value`, 0 if `left.value == right.value`, or 1 if `left.value > right.value`.

• ``` dataType ```

The type BasicType.DECIMAL.

#### Declaration

Swift

``override open var dataType: DataType``
• ``` equal(_:_:) ```

Compare two wrapped values for equality.

#### Declaration

Swift

``open class func equal(_ left: DecimalValue?, _ right: DecimalValue?) -> Bool``

#### Parameters

 ``` left ``` First object for comparison. ``` right ``` Second object for comparison.

#### Return Value

`true` if `left.value == right.value` or if both arguments are `nil`, otherwise `false`.

• ``` equals(_:) ```

#### Declaration

Swift

``override open func equals(_ value: AnyObject?) -> Bool``

#### Parameters

 ``` value ``` The value to compare with.

#### Return Value

`true` if this object is equal to `value`.

• ``` hashCode() ```

Hash the wrapped value to a number.

#### Declaration

Swift

``override open func hashCode() -> Int``

#### Return Value

Any value in the range of type `int`.

• ``` of(_:) ```

Wrap a `decimal` value as an object.

#### Declaration

Swift

``open class func of(_ value: BigDecimal) -> DecimalValue``

#### Parameters

 ``` value ``` Value to be wrapped.

#### Return Value

The wrapped value.

• ``` of(optional:) ```

Wrap a nullable `decimal` value as an object.

#### Declaration

Swift

``open class func of(optional value: BigDecimal?) -> DecimalValue?``

#### Parameters

 ``` value ``` Value to be wrapped.

#### Return Value

The wrapped value.

• ``` optional(_:) ```

Convert a wrapped `decimal` value to a nullable decimal.

Throws

`CastException` if `value` is not a wrapped `decimal` or `nil`.

#### Declaration

Swift

``open class func optional(_ value: AnyObject?) -> BigDecimal?``

#### Parameters

 ``` value ``` The wrapped value.

#### Return Value

A nullable decimal.

• ``` toString() ```

Convert this data value to a string. If the `dataType` is defined by XML Schema Part 2: Datatypes, then the corresponding lexical format is used. JSON format is used for structured values (arrays and objects).

#### Declaration

Swift

``override open func toString() -> String``

#### Return Value

Lexical representation of this data value.

• ``` typeCode ```

Data type code of the wrapped value, equivalent to `dataType.code`.

#### Declaration

Swift

``override open var typeCode: Int``
• ``` unwrap(_:) ```

Convert a wrapped `decimal` value to a decimal.

Throws

`CastException` if `value` is not a wrapped `decimal`.

#### Declaration

Swift

``open class func unwrap(_ value: AnyObject?) -> BigDecimal``

#### Parameters

 ``` value ``` The wrapped value.

#### Return Value

A decimal.

• ``` value ```

The wrapped value.

#### Declaration

Swift

``open var value: BigDecimal``