1

i have a compiled Vb .Net Program that have below Arithmetic line when i want to use this line in new App has different result the code is :

Protected Sub MethodOne(ByRef A_1 As UInteger,A_2 As UInteger,A_3 As UInteger,A_4 As UInteger,A_5 As UInteger,A_6 As UShort,A_7 As UInteger)
A_1 = A_2 + Class2.Method1(A_1 + ((A_2 And A_3) Or (Not A_2 And A_4)) + 127, A_6)
    End Sub

'==================================== method in Class2 difinition ====================

        Public Shared Function Method1(A_0 As UInteger, A_1 As UShort) As UInteger
                          Return A_0 >> CInt((32US - A_1)) Or A_0 << CInt(A_1)
        End Function

=================================================

with predefined values as

A_1 = 1732584193UI

A_2 = 4023233417UI

A_3 = 2562383102UI

A_4 = 271733878UI

A_5 = 0

A_6 = 7

A_7 = 0

when i Call MethodOne in Compiled App the Result of MethodOne is

    A_1 2770347892  uint

but when i Run Same Code in New App With Same A_1 to A_7 Values the Result is

    A_1 4023249673  uint

notice : in both Assembly i have turned on RuntimeCompatibilityAttribute:WrapNonExceptionThrows=true

What i have mistake ?

regards

Conry
  • 11
  • 2
  • "With Same A_1 to A_4 Values"... but `MethodOne` has other parameters, A_5 to A_7, which affect the calculation (well, A_6 does anyway). Are those input values different between your two apps? Or was this just a typo in your question, and you meant to say "With Same A_1 to A_7 Values"? – Sean Skelly Jul 21 '20 at 20:13
  • oh Sorry A_5 = 0 , A_6=7 , A_7=1 – Conry Jul 22 '20 at 04:08
  • Have you tried stepping through both apps in the debugger to see where they diverge? – Craig Jul 22 '20 at 13:14
  • @craig of course in old App MethodOne Send this expression A_1 + ((A_2 And A_3) Or (Not A_2 And A_4)) + 127 as "3614090487" but in new project just send "127" i think that's must related to something about integer Arithmetic in compiler i should mention that in both project i turn off integer overflow in compile option in project properties – Conry Jul 22 '20 at 15:36
  • If you're stepping through in the debugger, then the next thing I'd suggest to do is try putting a watch on subexpressions (or even assign them to variables). You may be able to find a specific piece that contributes to the overall difference. (e.g. check `A_2 And A_3` in both to make sure that's the same, check `Not A_2 And A_4`, then check results of both `Or`ed together, etc.) – Craig Jul 22 '20 at 16:01
  • RuntimeCompatibilityAttribute:WrapNonExceptionThrows=true? That wraps thrown objects that do not inherit from exception and has nothing to do with arithmetic overflow checks. – Christoph Jul 22 '20 at 22:53
  • Your calculation results in 4023249545 on my machine. But I suspect something is wrong with your formula anyway as argument 7 is not used at all, as I get an OverflowException if I do not explicitly suppress it and was forced to add an explicit cast from Int64 to UInt32 to get it running. – Christoph Jul 22 '20 at 22:57
  • i'v turnd on "overflow check" in compile tab of project properties – Conry Jul 23 '20 at 12:54

1 Answers1

0

that's all my fault in MethodOne " number 127 callback from an array thus i'v have to find the array what number callback anyway appreciate for your helps

Conry
  • 11
  • 2