Wrong expected output for A : -1 B : 1 C : 20


#1

Wrong expected output for A : -1 B : 1 C : 20 which is -19 according to you but it should be -1 according to me.


#2

no it’s +19 only because as per basics mathematics division rule you cannot substract the divident with its more that’s null and void, because modulo is different from division as it has to return an integer so in this case our quotient will be -1 and remainder will be -1-(-20)=19.
The logic which we actually used or perhaps you thought of that is valid for only division case because there we can return a floating value. For better clearance you can run a dry test you will get the idea!!!


#3

if anyone is using js modulo gives a different result, check this https://stackoverflow.com/questions/4467539/javascript-modulo-gives-a-negative-result-for-negative-numbers