Sunday, October 14, 2007

Dolphin's Float>>hash

While working on the hash book, I've run into a discrepancy I can't reconcile. I was looking at Dolphin's number hashes and, to make testing easier, I reimplemented Dolphin's Float>>hash in VW (remember that in Dolphin, aFloat is the equivalent of VW's aDouble). When I tested the reimplementation, I couldn't get the values to match.

Unable to see what was going on by looking at the code, I went into a VW workspace and tried to calculate the hash of 3.25d according to my interpretation of Dolphin's implementation. The answer was 3. Dolphin's workspace, however, said 3.25 hash was 879642989.

Ok, so obviously there was a bug in what I wrote. I brought up a side by side arrangement of debuggers to see what was going on. Much to my astonishment, the calculations matched on both sides, and in both cases the answer was 3.

This just can't be. Could somebody please point at what I am doing wrong?

Update: aha --- compile time literals strike again! Recompiling the method in Dolphin produces the right answer now.

No comments: