This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem in mod operation

Hi All,
i'm having a unique problem while taking the modulus of a number. please could any one help me out.

i)8432648 Mod 1048576 = 44040 i get 44040

ii)8498184 Mod 1048576 = 109576 i get 44040

iii)8563720 Mod 1048576 = 175112 iget 109576

iv)8629256 Mod 1048576 = 240648 i get 175112

v)8694792 Mod 1048576 = 306184 i get 240648

vi)8760328 Mod 1048576 = 371720 i get 306184

vii)8825864 Mod 1048576 = 437256 i get 437256

viii)8891400 Mod 1048576 = 502792 i get 437256

this just goes on. if u see the i) & vii) case i get the desired value but in the rest i get the value of privious number.

i am using aa=(aa%1048576); where aa is long int. and has values i denoted.

please could any one help me out with this.

Thanks
Ajay

Parents
  • Hi Drew & Dan,
    So let me see if i am interpreting this right all i have to do Take this code

    aa=(keyCode[7]+(keyCode[6]*10)+(keyCode[5]*100)+(keyCode[4]*1000)
    +(keyCode[3]*10000)+(keyCode[2]*100000)+
    (keyCode[1]*1000000)+(keyCode[0]*10000000));

    and replace it with this

    aa=(keyCode[7]+(keyCode[6]*10L)+(keyCode[5]*100L)+(keyCode[4]*1000)
    +(keyCode[3]*10000L)+(keyCode[2]*100000L)+
    (keyCode[1]*1000000L)+(keyCode[0]*10000000L));

    and it will convert all to long and addtion will be correct.

Reply
  • Hi Drew & Dan,
    So let me see if i am interpreting this right all i have to do Take this code

    aa=(keyCode[7]+(keyCode[6]*10)+(keyCode[5]*100)+(keyCode[4]*1000)
    +(keyCode[3]*10000)+(keyCode[2]*100000)+
    (keyCode[1]*1000000)+(keyCode[0]*10000000));

    and replace it with this

    aa=(keyCode[7]+(keyCode[6]*10L)+(keyCode[5]*100L)+(keyCode[4]*1000)
    +(keyCode[3]*10000L)+(keyCode[2]*100000L)+
    (keyCode[1]*1000000L)+(keyCode[0]*10000000L));

    and it will convert all to long and addtion will be correct.

Children
No data