Dekkonot / bitbuffer

A binary stream module for packing binary data in pure Lua
https://dekkonot.github.io/bitbuffer/
MIT License
44 stars 11 forks source link

[FEAT] read/writeUInt64 #34

Closed foxt closed 2 years ago

foxt commented 2 years ago

It seems interesting that a data storage system for Roblox can't even store Roblox IDs which have been over 32-bits for over a year.

It would great to see a read/writeUInt64 function added to this library!

Thanks!

Dekkonot commented 2 years ago

This was a deliberate choice. Numbers in Lua are doubles, which have 53 significant bits. Without some sort of bigint implementation (which is well outside of scope), it's impossible to actually have 64 bit integers. I'd rather not lie to people about the precision of integers because it seems like a footgun waiting to happen.

foxt commented 2 years ago

Thanks for your answer. Do you reckon using Float64 is a good substitute? (I'm not too familiar with binary data types so I'm not sure if that's the same as the Lua number type 😅 )

Dekkonot commented 2 years ago

Float64 is another name for a double, so I would use it if you need full precision. Its not interchangable with an Int64 necessarily, but with any number below 2^53 it is.