logoalt Hacker News

ModernMechtoday at 6:04 PM1 replyview on HN

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


Replies

canyptoday at 7:44 PM

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?