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. Public Function

parseInt

Public Function
std.fmt.parseInt
pub fn parseInt(comptime T: type, buf: []const u8, base: u8) ParseIntError!T

Parses the string buf as signed or unsigned representation in the specified base of an integral value of type T.

When base is zero the string prefix is examined to detect the true base:

  • A prefix of "0b" implies base=2,
  • A prefix of "0o" implies base=8,
  • A prefix of "0x" implies base=16,
  • Otherwise base=10 is assumed.

Ignores '_' character in buf. See also parseUnsigned.

Params

  • T: type
  • buf: []const u8
  • base: u8

Errors

Overflow

The result cannot fit in the type specified.

InvalidCharacter

The input was empty or contained an invalid character.

File

fmt.zig:322
322
323
324
pub fn parseInt(comptime T: type, buf: []const u8, base: u8) ParseIntError!T {
    return parseIntWithGenericCharacter(T, u8, buf, base);
}