Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

specialCases

Filter out special cases for log in bases {e,2,10}.

If x is finite and positive, returns null. Returns the appropriate NaN or inf otherwise.

log_f128.specialCases
pub fn specialCases(x: f128) ?f128

File

lib/compiler_rt/log_f128.zig:21

Code

pub fn specialCases(x: f128) ?f128 {
    if (!math.isFinite(x)) {
        if (math.isNan(x)) {
            if (math.isSignalNan(x)) math.raiseInvalid();
            return math.nan(f128);
        }
        if (math.isPositiveInf(x)) return x;
    }
    if (x <= 0.0) {
        if (x >= 0.0) {
            math.raiseDivByZero();
            return -math.inf(f128);
        }
        math.raiseInvalid();
        return math.nan(f128);
    }

    return null;
}