Thread Tools Display Modes
Prev Previous Post   Next Post Next
07/17/14, 04:28 AM   #16
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Originally Posted by zgrssd View Post
I asume AreId64sEqual does som additional checks. The logic most be more complex then A ~= B, if they write an extra function for it.
I don't think it's more complex, but is required due the way Lua stores numbers http://lua-users.org/wiki/NumbersTutorial

Since numbers in Lua are double-precision floating-point (1 bit sign, 11 bits exponent, 52 bits mantisa), integers are only precise below 2^53. Try comparing (2^53 == 2^53+1) in Lua console, the answer is surprisingly "true". That's because binary representation of 2^53+1 is "1..(52x0)..1", but there is not enough room to store 53 bits in mantisa, and so it gets rounded to 2^53.
NB for the curious: 2^53+1 or "1..(52x0)..1" is 54 bits long, but I wrote there's no room for 53 bits. It's not a typo, the initial "1" bit is implied, not stored anywhere. It's part of the standard https://en.wikipedia.org/wiki/IEEE_floating_point

They probably return the 64-bit integer ID in Lua number, but that's not guaranteed to be a valid floating-point number (some bit combinations are simply invalid, and floating-point operations on such values, including comparison, might yield weird results). Those comparison functions are probably circumventing floating-point comparison, and do integer comparison in C instead. But it's just my guess
  Reply With Quote
 

ESOUI » Developer Discussions » General Authoring Discussion » PTS 1.3.0 API changes (100007 to 100008 diff)


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off