Open lastmjs opened 2 weeks ago
u64 converting into a number is a design decision I made because it seemed reasonable. A JavaScript number can handle up to 52 bits without losing any precision and QuickJS API for big ints is very limited so we chose to have u64 convert into and from a number by default.
Rquickjs has a flexible API for converting types into and from js so if this behavior is not desired you can manually do the conversion or implement IntoJs and FromJs traits for a wrapper type.
A bigint shouldn't convert to a u64 unless explicitly done with the Coerce
type.
Hi, I would like some insight into u64 conversions from and into JavaScript. To me they seem incorrect.
When I return a u64 like this:
The runtime type of the returned value is a
number
. This does not seem correct as I don't believe the JavaScriptnumber
type can store allu64
s.IIRC I also had a bigint that I wanted to pass into Rust, but it was converted into an f64 or something.
Are there problems with the number conversions in rquickjs?
In my mind and working with other JavaScript engines I would expect bigints for things like u64 and u128...