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.
fnmodfGeneric(comptimeT: type, x: T, iptr: *T) T {
if (math.isNegativeInf(x)) {
iptr.* = -math.inf(T);
return -0.0;
}
if (math.isPositiveInf(x)) {
iptr.* = math.inf(T);
return0.0;
}
if (math.isNan(x)) {
iptr.* = math.nan(T);
returnmath.nan(T);
}
constr = math.modf(x);
iptr.* = r.ipart;
// If the result is a negative zero, we must be explicit about
// returning a negative zero.
returnif (math.isNegativeZero(x) or (x < 0.0andx == r.ipart)) -0.0elser.fpart;
}