New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix 064_builtins: @addWithOverflow() explanation #94
Conversation
The last two examples do not overflow, because the result is small enough. This was probably just a typing error in the original explanation.
@DerTee Thanks! Definitely an oversight. |
Is it really an oversight? I think the several lines show the process of adding 0101 to 1010 one by one. The two "YES!" show the overflow status of last two steps. At that time, the overflow has already happened and "Overflowed?" is "YES!". |
@ziyi-yan I thought about that too, but in the context of the builtin @addWithOverflow function that does not make sense, because it returns a result per operation, not for several operations. Also afaik the flags of CPUs are also set for the last operation. Also @ratfactor wrote the original text and confirmed it was an oversight, so I think everything is alright :) |
@ratfactor I actually think that incrementing a value up to and over the point where it overflows is a good idea. Removing the two lines that come after the overflow would help to not confuse people about the builtins exercise, but they might also come out with a false understanding of overflow. The crux is that counting up a variable and exceeding its capacity overflows only in one single Anyway, here's my shot at trying to make the
The full output would then look like this:
I'm not sure if it's really better, but I'm trying to be as constructive as I can and at least propose some solution. |
@DerTee Yeah, I see where you're going with that. It would be really nice to see the moment where the value overflowed! I've tried to keep the correct output of Ziglings exercises short to make them easy to check for correctness (at least partially inspired by the single numeric answers to exercises in https://projecteuler.net/). Originally, I was shooting for single line output, but that was too limiting. I'll have to think about this. The table of output would be really nice. |
Still thinking about this. I love the table idea, but would also like to avoid such a large "answer" output. Is there some way to display this same information in a compact way without losing too much clarity? |
@ratfactor Probably the best way is to not generate the table in code, but simply put the output table in the comments, just like you did originally. I have a draft we can have a look at. I'll push it into this PR as soon as I figure out the github stuff (I screwed something up locally). EDIT: can't figure out how to push into this PR. Maybe that's because it's closed, no idea. My draft for changes is here: DerTee@c94382b |
@DerTee Sorry for the delay getting back to you on this. I like what you've got! Yeah, do please create a new PR. I'm sure we can link the two somehow by mentioned this one in that one. |
fix 064_builtins: @addWithOverflow() explanation
… variable is set.' (ratfactor#94) from minor_improvements into main Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/94
The last two examples do not overflow, because the
result is small enough. This was probably just a typing
error in the original explanation.