acute blog in an obtuse world

Tuesday, July 17, 2007

x == y for very large values of x and y

Lately, I've been doing some work that has required me to look very closely at the way scripting languages represent scalar values internally and how they are represented when passed to and from a COM server.

The results are interesting, but the process of collection was not interesting at all, so if you need this information too, maybe I can save you some pain.

OK, what am I talking about?

Here's a little JScript puzzle to illustrate:

The Puzzle

var n = 0x0040000000000000;

var m = 0x0040000000000002;

var eq = (m == n);

If you run the code, what will the value of eq be?

The Answer

What's your answer?

You probably smell a rat here and answered "true." And you were right! But why were you right? Stay tuned for the details...

No comments: