Closed wwhurley closed 4 years ago
A 64-bit float is a double
, so you want to use .readDouble()
/ .writeDouble()
. The Memory.{read,write}*()
APIs are deprecated btw, so use methods on NativePointer
instead. (Also, Memory.readFloat()
returns a number
, not a string
.)
For dealing with 64-bit integers, the S64/U64 APIs accept Int64
and UInt64
values, which can be constructed from a string. (To avoid loss of precision, as JavaScript numbers are backed by double
.)
That's a little strange. Maybe it's because I was previously on 12.6 and just updated to 12.8. Is it possible to use writeDouble()
to use a BigInt or something that can hold a larger value than the JavaScript float? I'm trying to write -7728003924733680089
which after converting to a number in JavaScript comes out as -7728003787486396000
I'm trying to overwrite a section in memory that is defined as a Float, but it appears to be a 64-bit signed float. Using
Memory.readFloat()
I get values like-150525991776673600000
as a string. Then I'm attempting to useMemory.writeFloat()
to overwrite it with a value like-7728003924733680089
but I get an error that it expects a number. Unfortunately those numbers are too big to be correctly represented using JavaScript floats. I've tried usingMemory.readS64()
andMemory.readLong()
to make use of the Int64 value but I don't get correct values. Is there any way to prepare a value to be written in that fashion?