• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Solved] Same Value Returns Both 0.0 and NULL from Hashtable

Status
Not open for further replies.
The following code returns true for r == 0.0 and r == null. Can anyone tell me why? I would expect that only r==0.0 would return true.

JASS:
local unit t = GetTriggerUnit()
local real r = 0.0

//Save 0.0 value to hashtable
call SaveRealBJ(0.0, GetHandleIdBJ(t), 1, udg_hashTable)

//Other actions occur

//Load value from hashtable
set r = LoadRealBJ(GetHandleIdBJ(t), 1, udg_hashTable)

//Check value
if r == 0.0 then
    call BJDebugMsg("r = 0.0")
endif

if r == null then
    call BJDebugMsg("r is null")
endif

set t = null

I'm just starting to learn hashtables and I have been away from JASS for the better part of a year now, so I apologize if this is hashtable 101 and I'm just late to the party. Either way, any help would be very much appreciated.
 
Can anyone tell me why?
I can think of 2 possible reasons.
  1. The null value in JASS has an internal value of 0x00000000 and 0.0 represented in a IEEE 32bit float also has a value of 0x00000000.
  2. The real equality comparison operator has strange, non-primitive, behaviour. For example it checks if the numbers are approximately equal with a larger machine epsilon than the real type. There exists reals a and b where by a == b and a != b are both true. The null value might be handled by the equality comparison operator as a special case.
 
there is an easy method to check these values before Booleans.the simplest solution is to convert it into a string and then check the string

if(value=""+null){
Boolean = false;
}

else
{
\\do normal computing
}
 
Status
Not open for further replies.
Back
Top