zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

addWithOverflow_builtin.zig (285B) - Raw


      1 const print = @import("std").debug.print;
      2 pub fn main() void {
      3     const byte: u8 = 255;
      4 
      5     const ov = @addWithOverflow(byte, 10);
      6     if (ov[1] != 0) {
      7         print("overflowed result: {}\n", .{ov[0]});
      8     } else {
      9         print("result: {}\n", .{ov[0]});
     10     }
     11 }
     12 
     13 // exe=succeed