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

[BUG] double/float comparison not working #1658

Closed
1 task done
Talon1024 opened this issue Jul 6, 2022 · 13 comments
Closed
1 task done

[BUG] double/float comparison not working #1658

Talon1024 opened this issue Jul 6, 2022 · 13 comments
Labels

Comments

@Talon1024
Copy link
Contributor

Talon1024 commented Jul 6, 2022

GZDoom version

GZDoom g4.8.1

Which game are you running with GZDoom?

Doom 2

What Operating System are you using?

Linux x86_64

Please describe your specific OS version

Kubuntu 20.04 LTS

Relevant hardware info

Intel Core i3-3110M CPU, Intel HD Graphics 4000 GPU

Have you checked that no other similar issue already exists?

  • I have searched and not found similar issues.

A clear and concise description of what the bug is.

When doubles are compared to floats, the result is incorrect.

This has caused an issue in Wolfenstein: Blade of Agony where the player's disguise item makes them unable to move through doors or gates while crouching. I did a quick workaround, but that doesn't solve the issue.

The comparison works properly on GZDoom 4.7.1 because it converts the scale to doubles, but it does not work properly on GZDoom 4.8.1.

Here's a small mod demonstrating the issue.

Steps to reproduce the behaviour.

Explain how to reproduce

  1. Launch GZDoom with the test mod provided above, and start a new game.
  2. Enter give ScaleCompareTest into the console.
  3. If it works properly, you should see "Owner's scale is NOT 0.650." only once.

Your configuration

No response

Provide a Log

GZDoom 4.7.1 (correct):

MAP01 - Entryway

]give scalecomparetest
Owner's scale is NOT 0.650.
]give scalecomparetest
Owner's scale is already 0.650. Doing nothing
]give scalecomparetest
Owner's scale is already 0.650. Doing nothing

GZDoom 4.8.1 (incorrect):

MAP01 - Entryway

]give scalecomparetest
Owner's scale is NOT 0.650.
]give scalecomparetest
Owner's scale is NOT 0.650.
]give scalecomparetest
Owner's scale is NOT 0.650.
]give scalecomparetest
Owner's scale is NOT 0.650.
@Talon1024 Talon1024 added the bug label Jul 6, 2022
@Blue-Shadow
Copy link
Contributor

I believe this is already fixed in 4.8.2. So try that.

@Talon1024
Copy link
Contributor Author

Talon1024 commented Jul 6, 2022

No dice. I just tried this in GZDoom 4.8.2, and float/double comparisons don't work properly in 4.8.2 either.

@MrRaveYard
Copy link
Contributor

MrRaveYard commented Jul 7, 2022

I think this a float vs double precision issue.

float:
0.64999997615814208984375000000000000000000000000000000
double:
0.65000000000000002220446049250313080847263336181640625

@Talon1024
Copy link
Contributor Author

Was scale changed internally from double to float between GZDoom 4.7.1 and 4.8.0?

@MrRaveYard
Copy link
Contributor

Yes f9bf6f9

@OrdinaryMagician
Copy link
Contributor

Does it work if ~== is used instead of just ==?

@MrRaveYard
Copy link
Contributor

Does it work if ~== is used instead of just ==?

Nope

@coelckers
Copy link
Member

Looks like the scale vector needs to be reverted to double. Well, here goes the chance of saving some space in AActor... :(

@SanyaWaffles
Copy link
Contributor

That's a shame, but it seems this unfortunately breaks stuff too much with no obvious workaround.

@Talon1024
Copy link
Contributor Author

Looks like the scale vector needs to be reverted to double. Well, here goes the chance of saving some space in AActor... :(

Why not convert/coerce both values to float if either value being compared is a float?

@coelckers
Copy link
Member

Currently there are no float opcodes whatsoever, this would require a lot of support code.
I'm sorry, but as I see it, single precision floats in ZScript are not viable for anything that requires precise comparisons.

@coelckers
Copy link
Member

fixed in aae1d14

@SanyaWaffles
Copy link
Contributor

SanyaWaffles commented Jul 11, 2022

Still a few floats in actor.zs causing zscript compilation to fail.

EDIT: #1666

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

6 participants