mirror of
https://codeberg.org/andyscott/ziglings.git
synced 2024-12-22 06:03:09 -05:00
Merge pull request #321 from ratfactor/issue317
Fixed description of @addWithOverflow
This commit is contained in:
commit
cac5770e3c
2 changed files with 4 additions and 5 deletions
|
@ -13,7 +13,7 @@
|
||||||
// compiler, such as type introspection (the ability to examine
|
// compiler, such as type introspection (the ability to examine
|
||||||
// type properties from within a program).
|
// type properties from within a program).
|
||||||
//
|
//
|
||||||
// Zig currently contains 101 builtin functions. We're certainly
|
// Zig contains over 100 builtin functions. We're certainly
|
||||||
// not going to cover them all, but we can look at some
|
// not going to cover them all, but we can look at some
|
||||||
// interesting ones.
|
// interesting ones.
|
||||||
//
|
//
|
||||||
|
@ -28,8 +28,7 @@ const print = @import("std").debug.print;
|
||||||
pub fn main() void {
|
pub fn main() void {
|
||||||
// The second builtin, alphabetically, is:
|
// The second builtin, alphabetically, is:
|
||||||
// @addWithOverflow(a: anytype, b: anytype) struct { @TypeOf(a, b), u1 }
|
// @addWithOverflow(a: anytype, b: anytype) struct { @TypeOf(a, b), u1 }
|
||||||
// * 'T' will be the type of the other parameters.
|
// * 'a' and 'b' are numbers of anytype.
|
||||||
// * 'a' and 'b' are numbers of the type T.
|
|
||||||
// * The return value is a tuple with the result and a possible overflow bit.
|
// * The return value is a tuple with the result and a possible overflow bit.
|
||||||
//
|
//
|
||||||
// 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:
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
67c67
|
66c66
|
||||||
< const expected_result: u8 = ???;
|
< const expected_result: u8 = ???;
|
||||||
---
|
---
|
||||||
> const expected_result: u8 = 0b00010010;
|
> const expected_result: u8 = 0b00010010;
|
||||||
82c82
|
81c81
|
||||||
< const tupni: u8 = @bitReverse(input, tupni);
|
< const tupni: u8 = @bitReverse(input, tupni);
|
||||||
---
|
---
|
||||||
> const tupni: u8 = @bitReverse(input);
|
> const tupni: u8 = @bitReverse(input);
|
||||||
|
|
Loading…
Reference in a new issue