Finding the value based on the value of the remainder

In summary: I need the algorithm!In summary, you are looking for an algorithm to solve equations with two unknowns.
  • #36
Vital said:
Yes, I thought so also when I initially came up with this same equation, so I thought that my math is completely incorrect, and I started asking for help, because the program doesn't compute it this way somehow, and I get completely different results. Well, maybe it's some problem with computing the remainder when the quotient is negative. It might be the case. I have to investigate that further.
Thank you so much for your huge patience and your help!
Yes. I'm not sure about that "%" operation.

It appears that the values you are using for " i " also fall in the [ 0, 25 ] interval. If that's the case, and the problem is with computing the remainder for negatives, then adding 26 (or any positive multiple of 26), before applying the "%" operation should solve the problem.
 
Physics news on Phys.org
  • #37
SammyS said:
Yes. I'm not sure about that "%" operation.

It appears that the values you are using for " i " also fall in the [ 0, 25 ] interval. If that's the case, and the problem is with computing the remainder for negatives, then adding 26 (or any positive multiple of 26), before applying the "%" operation should solve the problem.
Thank you! I have to try this. There is a good thing about all this; I am glad that I am not that bad in the most basic math; I was so desperate that my equation didn't work, and I couldn't understand why, so I came here, and "tortured" you while the problem was in the way the program treats negatives. :-) Again, thank you very much for your help, and I will try the +26 trick. :-)

EDIT: I just did - added 26 to the equation, and, viola, it does the job! :) What a relief! ) Thank you so much! Now I need to understand my mistake in programming - it's not right that the program can't compute such remainders. :-)
 
  • #38
Vital said:
Thank you! I have to try this. There is a good thing about all this; I am glad that I am not that bad in the most basic math; I was so desperate that my equation didn't work, and I couldn't understand why, so I came here, and "tortured" you while the problem was in the way the program treats negatives. :-) Again, thank you very much for your help, and I will try the +26 trick. :-)

EDIT: I just did - added 26 to the equation, and, viola, it does the job! :) What a relief! ) Thank you so much! Now I need to understand my mistake in programming - it's not right that the program can't compute such remainders. :-)
Not tortured too much ! (Most of any torture there was, I inflicted upon myself.)

I'm glad to see that you at least got it to work, even if that's with a "trick".

What programming language?
The main issue is with the details of how the % operation is defined.
 
  • #39
SammyS said:
Not tortured too much ! (Most of any torture there was, I inflicted upon myself.)

I'm glad to see that you at least got it to work, even if that's with a "trick".

What programming language?
The main issue is with the details of how the % operation is defined.
It's C. :-) And it might be some issues with negatives, some nuances I still have to learn. But I can't discuss the programming itself, unfortunately, because I promised to the person who helps me with C, not to seek for any help when it comes to programming; so I can't break my promise. :-)
 
  • Like
Likes SammyS
  • #40
SammyS said:
Yes. I'm not sure about that "%" operation.
It has always annoyed me the way % works with negatives in C. Clearly not specified by a mathematician.
 
  • Like
Likes SammyS
  • #41
Back
Top