From b436392de9decd6e0172340e1d130871ebea1696 Mon Sep 17 00:00:00 2001 From: Anton <anton.frappe@outlook.com> Date: Tue, 2 Mar 2021 15:31:31 +0100 Subject: [PATCH] bare1_3 --- examples/rtic_bare1.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/rtic_bare1.rs b/examples/rtic_bare1.rs index 31b5636..a173320 100644 --- a/examples/rtic_bare1.rs +++ b/examples/rtic_bare1.rs @@ -76,7 +76,7 @@ const APP: () = { // // Explain in your own words the chain of calls. // -// App calls init, init initializes a mutable variable x to int max -1 +// App calls init, init initializes a mutable variable x to int max -2 // init loops while adding to x, x goes over max, rust calls panic // panic calls panic_format, panic_fmt calls semihosting_panic // panic semihosting calls brakpoint. @@ -92,11 +92,11 @@ const APP: () = { // // What is the value of `x`? // -// ** your answer here ** +// 4294967294 // // Explain in your own words where this value comes from. // -// ** your answer here ** +// core::u32::MAX = 4294967295 = 2^32-1; we assign x to be MAX-1 // // Now continue the program, since you are in a loop // the program will halt again at line 24. @@ -105,7 +105,7 @@ const APP: () = { // // Explain in your own words why `x` now has this value. // -// ** your answer here ** +// we added 1 to x // // Now continue again. // @@ -119,7 +119,9 @@ const APP: () = { // // Explain in your own words why a panic makes sense at this point. // -// ** your answer here ** +// Since x had the value of MAX which is the maximum value x can't get bigger. +// since the purpose of adding to a variable is to make it bigger, +// and if it can't get any bigger rust has chosen to panic. // // Commit your answer (bare1_3) // -- GitLab