% operator is used for what actually??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 2

% operator is used for what actually???

25th Oct 2019, 10:24 AM
praatek
3 Answers
+ 6
Hello !! You can try to search this question on Sololearn Q/A search bar so that you can get varied answers and to avoid duplicates. You can refer these threads : https://www.sololearn.com/discuss/2027540/?ref=app https://www.sololearn.com/discuss/2025684/?ref=app https://www.sololearn.com/discuss/2022851/?ref=app
25th Oct 2019, 10:36 AM
Nova
Nova - avatar
+ 2
Atleast % will be very useful when converting number of base x to number of base y. Example: Convert decimal (10th base) value of 598 to hexadecimal (16th base). First we would take remainder: 598 % 16 = 6 | 6 Store it and subtract it from the decimal. 598 - 6 = 592 Next we would divide 592 by 16: 592 / 16 = 37 And get to use modulo again annd repeat same tasks until we get 0: 37 % 16 = 5 | 5 37 - 5 = 32 32 / 16 = 2 2 % 16 = 2 | 2 2 - 2 = 0 In the end we'd've got 256, which is the correct result.
25th Oct 2019, 3:27 PM
Seb TheS
Seb TheS - avatar
+ 1
% used for Remainder 5 % 4=1
25th Oct 2019, 10:26 AM
estifanos
estifanos - avatar