• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

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

Not open for further replies.
Level 18
Nov 1, 2006
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.

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")

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

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.

Dr Super Good

Spell Reviewer
Level 64
Jan 18, 2005
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.
Level 19
Jul 2, 2011
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

Boolean = false;

\\do normal computing
Not open for further replies.