fix: under/overflow

This commit is contained in:
2025-04-22 09:17:30 +09:00
parent 88ddc6d810
commit 82ffbb8a31

View File

@@ -11,8 +11,8 @@ fn interpret(code: &str) {
match code_bytes[pc] as char {
'>' => head += 1,
'<' => head -= 1,
'+' => memory[head] += 1,
'-' => memory[head] -= 1,
'+' => memory[head] = memory[head].wrapping_add(1),
'-' => memory[head] = memory[head].wrapping_sub(1),
'.' => println!("{}", memory[head]),
',' => {
let mut input_buf = [0u8; 1];