Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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 standard library. Private Type Function

SignOf

Private Type Function
std.math.SignOf
fn SignOf(T: type) type

File

math.zig:1765
1765
1766
1767
1768
1769
1770
1771
1772
1773
fn SignOf(T: type) type {
    return switch (@typeInfo(T)) {
        .comptime_int, .comptime_float => comptime_int,
        .int => IntFittingRange(@max(minInt(T), -1), @min(maxInt(T), 1)),
        .float => IntFittingRange(-1, 1),
        .vector => |vec| @Vector(vec.len, SignOf(vec.child)),
        else => @compileError("Expected an int, float, or a vector of one, found " ++ @typeName(T)),
    };
}