Please explain the code

Can you please explain why we have written
new_hash=(new_hash-text[i-1]-‘a’+1)+mod)%mod
instead of
new_hash=(new_hash-text[i-1]-‘a’+1))%mod

Hey @raj.verma5454
First thing is
say we have to do (5)%8
then 5%8 and (5+8r)%8==(5%8+8r%8)%8=(5%8+0)%8=5%8 so both are same

Second thing
we do this when in a%b a is negative say we have to do (-5)%8 then its 3
so we do (-5+8)%8=(3%8)=3

so these two statements are equal new_hash=(new_hash-text[i-1]-‘a’+1)+mod)%mod and new_hash=(new_hash-text[i-1]-‘a’+1))%mod

Yes when the number is positive
For negative nos we have to add mod and then take mod