Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpreter: Subtracting negative int value from a float value produces unexpected result #488

Closed
phobos2077 opened this issue Jul 22, 2023 · 2 comments
Labels

Comments

@phobos2077
Copy link
Collaborator

display_msg(""+(0.2000 - (-1)));

This code prints "-4294967296.00000" but expected "-0.80000"

@phobos2077 phobos2077 added the bug label Jul 22, 2023
@phobos2077
Copy link
Collaborator Author

Seems like vanilla issue, error must be somewhere here:

0046A2C0 loc_46A2C0:                                  ; op_sub_+DC�j
0046A2C0            mov     eax, [esp+34h+var_20]
0046A2C4            xor     ebp, ebp
0046A2C6            mov     dword ptr [esp+34h+var_34], eax
0046A2C9            mov     dword ptr [esp+34h+var_34+4], ebp
0046A2CD            fild    [esp+34h+var_34]
0046A2D0            fsubr   [esp+34h+var_24]
0046A2D4
0046A2D4 loc_46A2D4:                                  ; op_sub_+E6�j
0046A2D4            fstp    [esp+34h+var_28]
0046A2D8            mov     ebx, [esp+34h+var_28]
0046A2DC            lea     edx, [ecx+24h]
0046A2DF            mov     eax, [ecx+1Ch]

var_20 is the second (integer) operand. Seems like it should convert integer to float but it does something like reinterpret_cast<float> instead.

@phobos2077
Copy link
Collaborator Author

phobos2077 commented Jul 22, 2023

Turns out on September 11, 2014 I fixed the same issue in op_div and op_mult (on SVN repo), but apparently missed op_sub. Surprising this had to wait 9 years to get fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant