modulo - VB6 Mod function gives incorrect values with negative values -
i have step in script in vb6 failing. code follows
output = ((azmnum + steps ) mod 16777216)
the values variables in function
-850344 = (5184326 + -6034670) mod 16777216)
all variables long numbers. other programs enter these values (python , excel) return 15926872. can't figure out why modulo being ignored.
mod not same in languages, negative numbers. vb6 (and whole load of other compilers c, c++, c#, java) takes fortran interpretation remainder after dividing. mathematically, wrong interpretation if number negative. have is
5184326 + -6034670 = -850344 -850344 mod 16777216 = -850344
python , excel take correct interpretation of modulo result positive. takes step i.e.
-850344 + 16777216 = 15926872
Comments
Post a Comment