Skip to main content

try_f64_to_decimal

Function try_f64_to_decimal 

Source
pub unsafe fn try_f64_to_decimal(
    value: f64,
    width: u8,
    scale: u8,
) -> Option<Decimal>
Expand description

Converts an f64 into a DECIMAL(width, scale) like f64_to_decimal, or None when it cannot.

It cannot when the value does not fit, it is NaN or infinite, width is 0 or exceeds 38, or scale exceeds width.

DuckDB signals a failed conversion by returning width 0; a successful one carries the requested width, so the two cannot be confused once a width of 0 is refused up front.

ยงSafety

See date_from_days.