DoxigAlpha

modf

Returns the integer and fractional floating-point numbers that sum to x. The sign of each result is the same as the sign of x. In comptime, may be used with comptime_float

Special Cases:

  • modf(+-inf) = +-inf, nan
  • modf(nan) = nan, nan

Function parameters

Parameters

#
x:anytype

Functions in this namespace

Functions

#
modf
Returns the integer and fractional floating-point numbers that sum to x.

Source

Implementation

#
pub fn modf(x: anytype) Modf(@TypeOf(x)) {
    const ipart = @trunc(x);
    return .{
        .ipart = ipart,
        .fpart = x - ipart,
    };
}