← Back to context

Comment by ModernMech

2 hours ago

Here's an implementation of such: https://docs.rs/nanval/latest/nanval/

I still don't get what is the advantage over an unsigned integer. Yes, fp64 has unused bits. But why are you going to involve the FPU at all when a uint64 does the trick as well? Plus with a uint64 you get all the flexibility of what bits to dedicate to the address vs metadata.

Edit: I guess one advantage is that, if we later treat the handle like a pointer, NaN math gets you NaN again, whereas the uint64 math might get you an invalid address, or you'd need extra logic to check that the uint64 is not a valid handle?