Mallard
Search Results for

    Show / Hide Table of Contents

    Struct DuckDbDecimal

    DuckDB's representation of a floating-point decimal number.

    Inherited Members
    ValueType.Equals(object)
    ValueType.GetHashCode()
    ValueType.ToString()
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Mallard.Types
    Assembly: Mallard.dll
    Syntax
    public readonly struct DuckDbDecimal
    Remarks

    This structure does not represent the form of decimal numbers that DuckDB encodes in its vectors (which are instead short, int, long, Int128 depending on the width of the DECIMAL type set on the column). Rather it is the most general form of decimal number that may be read or written to DuckDB.

    In this library, this type may be used as an alternative to the standard decimal type. Some decimal numbers that are very large in magnitude (taking more than 96 bits) are not representable in decimal. Use this type if you need to read or write such decimal numbers.

    Methods

    | Edit this page View Source

    ConvertToDecimal(Int128, byte)

    Instantiate decimal with a full 128-bit significand.

    Declaration
    public static decimal ConvertToDecimal(Int128 value, byte scale)
    Parameters
    Type Name Description
    Int128 value

    Signed value of the significand.

    byte scale

    Number of digits after the decimal point.

    Returns
    Type Description
    decimal
    | Edit this page View Source

    ConvertToDecimal(short, byte)

    Instantiate decimal with a 16-bit significand (e.g. as obtained from a DuckDB vector).

    Declaration
    public static decimal ConvertToDecimal(short value, byte scale)
    Parameters
    Type Name Description
    short value

    Signed value of the significand.

    byte scale

    Number of digits after the decimal point.

    Returns
    Type Description
    decimal
    | Edit this page View Source

    ConvertToDecimal(int, byte)

    Instantiate decimal with a 32-bit significand (e.g. as obtained from a DuckDB vector).

    Declaration
    public static decimal ConvertToDecimal(int value, byte scale)
    Parameters
    Type Name Description
    int value

    Signed value of the significand.

    byte scale

    Number of digits after the decimal point.

    Returns
    Type Description
    decimal
    | Edit this page View Source

    ConvertToDecimal(long, byte)

    Instantiate decimal with a 64-bit significand (e.g. as obtained from a DuckDB vector).

    Declaration
    public static decimal ConvertToDecimal(long value, byte scale)
    Parameters
    Type Name Description
    long value

    Signed value of the significand.

    byte scale

    Number of digits after the decimal point.

    Returns
    Type Description
    decimal
    | Edit this page View Source

    FromDecimal(decimal)

    Convert a .NET decimal to a DuckDB decimal.

    Declaration
    public static DuckDbDecimal FromDecimal(decimal input)
    Parameters
    Type Name Description
    decimal input

    The value to convert.

    Returns
    Type Description
    DuckDbDecimal

    DuckDB representation of the value.

    | Edit this page View Source

    ToDecimal()

    Convert from DuckDB's representation of a decimal number to a .NET decimal.

    Declaration
    public decimal ToDecimal()
    Returns
    Type Description
    decimal

    The converted value.

    Exceptions
    Type Condition
    OverflowException

    The decimal value encoded by this instance cannot be fit into .NET's decimal type.

    Operators

    | Edit this page View Source

    implicit operator DuckDbDecimal(decimal)

    Implicit conversion.

    Declaration
    public static implicit operator DuckDbDecimal(decimal input)
    Parameters
    Type Name Description
    decimal input

    The .NET value to convert from.

    Returns
    Type Description
    DuckDbDecimal

    The converted value for DuckDB. This conversion always succeeds.

    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX