ziglings/exercises
62
1.5k
Fork
You've already forked exercises
478

ex. 72: overflow of integer type 'u8' with value '-16' #14

Closed
opened 2023年10月09日 20:56:21 +02:00 by aryzing · 1 comment

Not sure if there's any changes that are expected to be made to this line in exercise 72,

// This gets the digit from the "instruction". Can you// figure out why we subtract '0' from it?comptimevardigit=instructions[i+1]-'0';

The compiler is reporting an error for this line,

exercises/072_comptime7.zig:42:50: error: overflow of integer type 'u8' with value '-16'
 comptime var digit = instructions[i + 1] - '0';
 ~~~~~~~~~~~~~~~~~~~~^~~~~

Is anything required of users on this line or is this a bug with the exercise? Using Zig version 0.12.0-dev.798+5a4a5875d

Not sure if there's any changes that are expected to be made to this line in exercise 72, ```zig // This gets the digit from the "instruction". Can you // figure out why we subtract '0' from it? comptime var digit = instructions[i + 1] - '0'; ``` The compiler is reporting an error for this line, ``` exercises/072_comptime7.zig:42:50: error: overflow of integer type 'u8' with value '-16' comptime var digit = instructions[i + 1] - '0'; ~~~~~~~~~~~~~~~~~~~~^~~~~ ``` Is anything required of users on this line or is this a bug with the exercise? Using Zig version `0.12.0-dev.798+5a4a5875d`
Author
Copy link

Turns out the continue expression a few lines above was incorrect, causing the wrong characters to be used in the subtraction.

Turns out the continue expression a few lines above was incorrect, causing the wrong characters to be used in the subtraction.
Sign in to join this conversation.
No Branch/Tag specified
main
v0.16.0
v0.15.1
v0.14.0
v0.13.0
v0.12.0
v0.11.0
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ziglings/exercises#14
Reference in a new issue
ziglings/exercises
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?