Module org.firebirdsql.jaybird
Package org.firebirdsql.extern.decimal

# Class Decimal64

java.lang.Object
org.firebirdsql.extern.decimal.Decimal<Decimal64>
org.firebirdsql.extern.decimal.Decimal64

public final class Decimal64 extends Decimal<Decimal64>
An IEEE-754 Decimal64.

Author:
  Mark Rotteveel

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final Decimal64`
  `NEGATIVE_INFINITY`
  `static final Decimal64`
  `NEGATIVE_NAN`
  `static final Decimal64`
  `NEGATIVE_SIGNALING_NAN`
  `static final Decimal64`
  `POSITIVE_INFINITY`
  `static final Decimal64`
  `POSITIVE_NAN`
  `static final Decimal64`
  `POSITIVE_SIGNALING_NAN`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static Decimal64`
  `parseBytes(byte[] decBytes)`
  Parses the provided byte array to a `Decimal64`.
  `static Decimal64`
  `valueOf(double value)`
  Creates a `Decimal64` from `value`, applying rounding where necessary.
  `static Decimal64`
  `valueOf(double value, OverflowHandling overflowHandling)`
  Creates a `Decimal64` from `value`, applying rounding where necessary.
  `static Decimal64`
  `valueOf(String value)`
  Creates a `Decimal64` from `value`, applying rounding where necessary.
  `static Decimal64`
  `valueOf(String value, OverflowHandling overflowHandling)`
  Creates a `Decimal64` from `value`, applying rounding where necessary.
  `static Decimal64`
  `valueOf(BigDecimal value)`
  Creates a `Decimal64` from `value`, applying rounding where necessary.
  `static Decimal64`
  `valueOf(BigDecimal value, OverflowHandling overflowHandling)`
  Creates a `Decimal64` from `value`, applying rounding where necessary.
  `static Decimal64`
  `valueOf(BigInteger value)`
  Creates a `Decimal64` from `value`, applying rounding where necessary.
  `static Decimal64`
  `valueOf(BigInteger value, OverflowHandling overflowHandling)`
  Creates a `Decimal64` from `value`, applying rounding where necessary.
  `static Decimal64`
  `valueOf(Decimal<?> decimal)`
  Converts a decimal to Decimal64.
  `static Decimal64`
  `valueOf(Decimal<?> decimal, OverflowHandling overflowHandling)`
  Converts a decimal to Decimal64.
  `static Decimal64`
  `valueOfExact(BigInteger value)`
  Creates a `Decimal64` from `value`, rejecting values that would lose precision due to rounding.

  ### Methods inherited from class org.firebirdsql.extern.decimal.Decimal

  `doubleValue, equals, hashCode, toBigDecimal, toBytes, toDecimal, toDecimal, toString`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### POSITIVE_INFINITY

    public static final Decimal64 POSITIVE_INFINITY

  - ### NEGATIVE_INFINITY

    public static final Decimal64 NEGATIVE_INFINITY

  - ### POSITIVE_NAN

    public static final Decimal64 POSITIVE_NAN

  - ### NEGATIVE_NAN

    public static final Decimal64 NEGATIVE_NAN

  - ### POSITIVE_SIGNALING_NAN

    public static final Decimal64 POSITIVE_SIGNALING_NAN

  - ### NEGATIVE_SIGNALING_NAN

    public static final Decimal64 NEGATIVE_SIGNALING_NAN

- ## Method Details

  - ### parseBytes

    public static Decimal64 parseBytes(byte[] decBytes)
    Parses the provided byte array to a `Decimal64`.

    This method parses network byte-order (aka big-endian). When using little-endian order, you will need to reverse the bytes in the array first.

    Parameters:
      `decBytes` - Bytes of the Decimal64 value in network byte-order (aka big-endian)
    Returns:
      Instance of `Decimal64`
    Throws:
      `IllegalArgumentException` - When `decBytes` is not 8 bytes long

  - ### valueOf

    public static Decimal64 valueOf(BigDecimal value)
    Creates a `Decimal64` from `value`, applying rounding where necessary.

    Values exceeding the range of this type will be returned as +/-Infinity.

    Parameters:
      `value` - Big decimal value to convert
    Returns:
      Decimal64 equivalent

  - ### valueOf

    public static Decimal64 valueOf(BigDecimal value, OverflowHandling overflowHandling)
    Creates a `Decimal64` from `value`, applying rounding where necessary.

    Values exceeding the range of this type will be handled according to the specified overflow handling.

    Parameters:
      `value` - Big decimal value to convert
      `overflowHandling` - Overflow handling to apply
    Returns:
      Decimal64 equivalent
    Throws:
      `DecimalOverflowException` - If `OverflowHandling#THROW_EXCEPTION` and the value is out of range.

  - ### valueOf

    public static Decimal64 valueOf(BigInteger value)
    Creates a `Decimal64` from `value`, applying rounding where necessary.

    Values exceeding the range of this type will be returned as +/-Infinity.

    Parameters:
      `value` - Big integer value to convert
    Returns:
      Decimal64 equivalent

  - ### valueOf

    public static Decimal64 valueOf(BigInteger value, OverflowHandling overflowHandling)
    Creates a `Decimal64` from `value`, applying rounding where necessary.

    Values exceeding the range of this type will be handled according to the specified overflow handling.

    Calling this method is equivalent to `valueOf(new BigDecimal(value), overflowHandling)`.

    Parameters:
      `value` - Big integer value to convert
      `overflowHandling` - Handling of overflows
    Returns:
      Decimal64 equivalent
    Throws:
      `DecimalOverflowException` - If `OverflowHandling#THROW_EXCEPTION` and the value is out of range.
    See Also:
      - `valueOfExact(BigInteger)`

  - ### valueOfExact

    public static Decimal64 valueOfExact(BigInteger value)
    Creates a `Decimal64` from `value`, rejecting values that would lose precision due to rounding.
    Parameters:
      `value` - Big integer value to convert
    Returns:
      Decimal64 equivalent
    Throws:
      `DecimalOverflowException` - If the value is out of range.
    See Also:
      - `valueOf(BigInteger, OverflowHandling)`

  - ### valueOf

    public static Decimal64 valueOf(double value)
    Creates a `Decimal64` from `value`, applying rounding where necessary.

    `Double.NaN` is mapped to positive NaN, the infinities to their equivalent +/- infinity.

    For normal, finite, values, this is equivalent to `valueOf(BigDecimal.valueOf(value))`.

    Parameters:
      `value` - Double value
    Returns:
      Decimal equivalent

  - ### valueOf

    public static Decimal64 valueOf(double value, OverflowHandling overflowHandling)
    Creates a `Decimal64` from `value`, applying rounding where necessary.

    `Double.NaN` is mapped to positive NaN, the infinities to their equivalent +/- infinity.

    For normal, finite, values, this is equivalent to `valueOf(BigDecimal.valueOf(value), overflowHandling)`.

    Parameters:
      `value` - Double value
      `overflowHandling` - Overflow handling to apply
    Returns:
      Decimal equivalent
    Throws:
      `DecimalOverflowException` - If `OverflowHandling#THROW_EXCEPTION` and the value is out of range.

  - ### valueOf

    public static Decimal64 valueOf(Decimal<?> decimal)
    Converts a decimal to Decimal64.

    For normal, finite, decimals, this behaves like `valueOf(decimal.toBigDecimal())`, see `valueOf(BigDecimal)`.

    Parameters:
      `decimal` - Decimal to convert
    Returns:
      Decimal converted to Decimal64, or `decimal` itself if it already is Decimal64

  - ### valueOf

    public static Decimal64 valueOf(Decimal<?> decimal, OverflowHandling overflowHandling)
    Converts a decimal to Decimal64.

    For normal, finite, decimals, this behaves like `valueOf(decimal.toBigDecimal(), overflowHandling)`, see `valueOf(BigDecimal, OverflowHandling)`.

    Parameters:
      `decimal` - Decimal to convert
      `overflowHandling` - Overflow handling to apply
    Returns:
      Decimal converted to Decimal64, or `decimal` itself if it already is Decimal64
    Throws:
      `DecimalOverflowException` - If `OverflowHandling#THROW_EXCEPTION` and the value is out of range.

  - ### valueOf

    public static Decimal64 valueOf(String value)
    Creates a `Decimal64` from `value`, applying rounding where necessary.

    Except for the special values [+/-]Inf, [+/-]Infinity, [+/-]NaN and [+/-]sNaN (case insensitive), the rules of `BigDecimal(String)` apply, with special handling in place to discern between positive and negative zero.

    Values exceeding the range of this type will be returned as +/-Infinity.

    Parameters:
      `value` - String value to convert
    Returns:
      Decimal equivalent
    Throws:
      `NumberFormatException` - If the provided string is not valid numeric string.

  - ### valueOf

    public static Decimal64 valueOf(String value, OverflowHandling overflowHandling)
    Creates a `Decimal64` from `value`, applying rounding where necessary.

    Except for the special values [+/-]Inf, [+/-]Infinity, [+/-]NaN and [+/-]sNaN (case insensitive), the rules of `BigDecimal(String)` apply, with special handling in place to discern between positive and negative zero.

    Values exceeding the range of this type will be handled according to the specified overflow handling.

    Parameters:
      `value` - String value to convert
      `overflowHandling` - Overflow handling to apply
    Returns:
      Decimal equivalent
    Throws:
      `NumberFormatException` - If the provided string is not valid numeric string.
      `DecimalOverflowException` - If `OverflowHandling#THROW_EXCEPTION` and the value is out of range.