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

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -