• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

What is this BS?

Status
Not open for further replies.
Level 4
Joined
Sep 13, 2014
Messages
106
Code:
if (0 - 0 == 0) then
    call BJDebugMsg("1")
else
    call BJDebugMsg("2")
endif

if (0 - 0 != 0) then
    call BJDebugMsg("1")
else
    call BJDebugMsg("2")
endif

if (0 - 0.0 == 0) then
    call BJDebugMsg("a")
else
    call BJDebugMsg("b")
endif

if (0 - 0.0 != 0) then
    call BJDebugMsg("a")
else
    call BJDebugMsg("b")
endif

Using this code I get the following output:

1
2
a
a

Could someone tell me why? Is this a bug in the world editor or is it working as intended? Also, I find it annoying how dividing by 0 stops execution of the script rather than just being ignored or outputting 0 or NaN, since there is no way to handle errors.

It's super annoying, how can I determine whether (some real variable that could be equal to 0 subtracted from another real variable that could be equal to 0) is equal to 0 without it thinking that 0.1 is equal to 0?

It only occurs when 0 is subtracted from 0, and the subtractor is a real. if either is non-zero than it will work correctly. But I don't want to have to check whether one is non-zero, in fact the whole purpose of this is to get around the fact that dividing by 0 will stop execution, and I do this by checking if the divisor is equal to 0. I don't want yet another step to check whether one part of the divisor is equal to 0. Maybe I could instead check whether one is equal to the other, but it's still super annoying and buggy.

I think I can get around this now, by using:

if (1 != 0.0) then
call BJDebugMsg("a")
else
call BJDebugMsg("b")
endif

if (1 == 0.0) then
call BJDebugMsg("a")
else
call BJDebugMsg("b")
endif

But it is still super annoying and buggy, and it made me spend a while trying to fix my perfectly OK code.

Actually, I fixed my problem, maybe someone would like to move this thread to patch discussion or something (as a bug report) or even delete it.
 
Last edited:
Status
Not open for further replies.
Top