mirror of
https://codeberg.org/andyscott/ziglings.git
synced 2024-11-13 21:40:46 -05:00
commit
c2cd1472a4
1 changed files with 3 additions and 6 deletions
|
@ -26,14 +26,11 @@
|
||||||
const print = @import("std").debug.print;
|
const print = @import("std").debug.print;
|
||||||
|
|
||||||
pub fn main() void {
|
pub fn main() void {
|
||||||
// The first builtin, alphabetically, is:
|
// The second builtin, alphabetically, is:
|
||||||
//
|
// @addWithOverflow(a: anytype, b: anytype) struct { @TypeOf(a, b), u1 }
|
||||||
// @addWithOverflow(comptime T: type, a: T, b: T, result: *T) bool
|
|
||||||
// * 'T' will be the type of the other parameters.
|
// * 'T' will be the type of the other parameters.
|
||||||
// * 'a' and 'b' are numbers of the type T.
|
// * 'a' and 'b' are numbers of the type T.
|
||||||
// * 'result' is a pointer to space you're providing of type T.
|
// * The return value is a tuple with the result and a possible overflow bit.
|
||||||
// * The return value is true if the addition resulted in a
|
|
||||||
// value over or under the capacity of type T.
|
|
||||||
//
|
//
|
||||||
// Let's try it with a tiny 4-bit integer size to make it clear:
|
// Let's try it with a tiny 4-bit integer size to make it clear:
|
||||||
const a: u4 = 0b1101;
|
const a: u4 = 0b1101;
|
||||||
|
|
Loading…
Reference in a new issue