HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Just An Other Jass Bug?

01-05-2009, 03:08 PM#1
DioD
Copy this to new trigger.
Then run map and press ESC.

Collapse JASS:

function B2Sx takes boolean Boolean returns nothing
    if Boolean then
        call BJDebugMsg("|cffccffccTrue|r")
    else
        call BJDebugMsg("|cffffccccFalse|r")
    endif
endfunction

function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing

    call B2Sx(not (0.999 != 1.000)) //Return FALSE
    call B2Sx((0.999 == 1.000)) //Return TRUE
    
    call B2Sx(not (1.0 != 2.0)) //Return FALSE
    call B2Sx((1.0 == 2.0)) //Return FALSE
    
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerRegisterPlayerEventEndCinematic( gg_trg_Untitled_Trigger_001, Player(0) )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction

01-05-2009, 03:36 PM#2
akolyt0r
what you put in comments there, is that the actual output ?
if yes, it is everything alright and functions as intended
01-05-2009, 03:40 PM#3
C2H3NaO2
rounding errors happens with real's.
Direct comparison between reals is usually not good.
I use RAbsBJ(r1-r2) < tolerance in cases like this.
01-05-2009, 03:49 PM#4
chobibo
Isn't that associated with how warcraft handles reals?

EDIT:
Quote:
Originally Posted by C2H3NaO2
rounding errors happens with real's.
Direct comparison between reals is usually not good.
I use RAbsBJ(r1-r2) < tolerance in cases like this.
Yeah this must be it, thanks dude.
01-05-2009, 03:57 PM#5
DioD
Equal check uses real rounding.
Not Equal - dont round reals.
01-05-2009, 04:03 PM#6
chobibo
call B2Sx(not (0.999 != 1.000)) //Return FALSE
Oh! I didn't know that lol, great find Diod!
01-05-2009, 04:11 PM#7
DioD
Can anyone benchmark:

Collapse JASS:
function One takes nothing returns nothing
local boolean A = (not (0.999 != 1.000))
endfunction

vs

function One takes nothing returns nothing
local boolean A = ((0.999 - 1.000) == 0.0)
endfunction
01-05-2009, 04:42 PM#8
C2H3NaO2
Collapse JASS:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
    local integer sw = StopWatchCreate()
    local real array r
    local integer i
    local boolean A
    
    set i = 0
    set r[0] = StopWatchMark(sw)
    loop
        exitwhen i == 12000
        set A = (not (0.999 != 1.000))
        set i = i + 1
    endloop
    set r[1] = StopWatchMark(sw)
    
    set i = 0
    call TriggerSleepAction(0.0)
    
    set r[2] = StopWatchMark(sw)
    loop
        exitwhen i == 12000
        set A = ((0.999 - 1.000) == 0.0)
        set i = i + 1
    endloop
    set r[3] = StopWatchMark(sw)
    call BJDebugMsg(R2S(r[1]-r[0]))
    call BJDebugMsg(R2S(r[3]-r[2]))
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerRegisterPlayerEventEndCinematic( gg_trg_Untitled_Trigger_001, Player(0) )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction

first 0.019-0.023
secound 0.023
I tried it 7 times.

(JNGP 5.1; japi; Wc3 1.21b)

Maybe it changed with the new patch/compiler.
01-05-2009, 04:58 PM#9
DioD
Looks like i have nothing to fix, both ways equal.
Thx for benchmark.

Sadly i cant rep+ you again today.
01-05-2009, 05:18 PM#10
Troll-Brain
EDIT : I said the order of the real in the comparison does matter sometimes but it's false, i miss read the displayed strings ...

Here is a test map anyway :

Expand JASS:

If you can't use Jasshelper, i have attached a demo map, don't try to save it, just start it with war3

Commands :

Code:
- press the escape key to display results
- type "reverse" will set R1 to R2 and R2 to R1 (not case sensitive)
- "R1 X" will set R1 to X (not case sensitive)
- "R2 X" will set R2 to X (not case sensitive)
Attached Files
File type: w3mBugRealComparaisons.w3m (17.1 KB)
01-06-2009, 03:31 AM#11
DioD
Bug of total real comparison ownage.

(0.999 == 1.000) == (0.999 != 1.000) TRUE!!!
01-06-2009, 07:15 PM#12
Toadcop
masda70 posted this ~1.5+ years before =) w8 i may find the thread...

http://www.google.com.ua/search?hl=ru&q=masda70&meta= :P

http://wc3campaigns.net/showthread.php?t=93006

well it's not 100% the same as in this thread told but i think in whole it's the same stuff.

and btw imo it's IEEE issue...
01-06-2009, 07:15 PM#13
Troll-Brain
IEEE means ?
01-06-2009, 07:48 PM#14
akolyt0r
IEEE gives out standards, on how technology has to handle certain things ...blablah ...
maybe he means the IEEE 754 Standard or something similar ...it tells how floating point numbers (floats,doubles,longs) are saved in memory and stuff ...dunno excactly what this has to do with this "problem" here.
Anyway its surely more of a "feature" then an issue -.-'