chars and percent - C#
Go to solution
Solved by 79wjd,
Ehm, ok...
So, 97%96 means that there is a reminder of 1?
And 97%122 means that there is an overflow and returns 97?
Is that right?
If yes, then why does 97%122 return 97? Why not something easier to understand (or something...)?
Because modulo arithmetic is very useful the way it is (and it's like that because of the way it works).
It returning 97 is actually a good thing.
Say I wanted to iterate through an array infinitely with entries being overwritten when I've exceeded the size of the array. If 97%122 returned anything other than 97, then I would have to computer 97 from whatever the return value was if I wanted to write whatever data I had to element 97.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now