3 ms·
It would be "2^32", not "2^32+1". 2^32 isn't representable in a 32-bit integer, the same way 256 isn't representable in an 8-bit integer--the maximum is 2^8-1,
by wahern 6y ago
It would be "2^32", not "2^32+1". 2^32 isn't representable in a 32-bit integer, the same way 256 isn't representable in an 8-bit integer--the maximum is 2^8-1, or 255.
But the argument that they need to represent 2^32 and therefore that's why they used 64-bit integers is dubious. No 32-bit WebAssembly program could ever operate on and pass an object as large as 2^32 bytes because the code and data structures for the smallest possible program would already take up more than 1 byte in that 32-bit address space.
- snek 6y agoAs is mentioned in the article, u64 was used to future proof for wasm's upcoming memory64 type: https://github.com/WebAssembly/memory64/blob/master/proposals/memory64/Overview.md https://github.com/WebAssembly/memory64/blob/master/proposal...
- Ericson2314 6y agoYeah, so what are they going to do when they then claim to need to to represent the length 2^64?
- colejohnson66 6y agoIf you have 2^64 objects, you have a bigger problem.
- Dylan16807 6y agoThat won't happen on a 64 bit machine. By the time we need that, the code will be so vastly different that trying to prepare for it now would be counterproductive.
- Ericson2314 6y agoI agree it's stupid. I think worrying about representing the length of 1 object filling the entire address space is stupid, wether the address space is 2^32 or 2^64
- Dylan16807 6y ago> representing the length of 1 object filling the entire address space Isn't this about encoding the WASM address space itself, inside the outer computer's 64 bit address space? It's only a slight annoyance if it doesn't get to be quite the normal limit, but since they're changing some of this code anyway, and they're going to need even bigger numbers in the future, it makes sense to do a proper adaptation.
- BubRoss 6y agoIf 32 bit is from your face to your hand, 64 bit is from you to the sun. You aren't going to need that on a single computer in your lifetime.