-
Notifications
You must be signed in to change notification settings - Fork 7
toString implementation on i32 produces surprising results #108
Comments
Just from what I would imagine (putting the wasm code in would help), this is casting the string to a number, but that means it's casting the location of the string? I could be completely wrong |
I am pretty sure that |
You can also use As for |
It also seems that // portable
let someFloat: f32 = 1.5
let someInt: i32 = i32(someFloat) becomes var someFloat = 1.5
var someInt = someFloat | 0 |
added by @vgrichina via Slack thread |
everyone replying here seems clear on this, it's just my confusion. this kind of thinking is out of my comfort zone at the moment so i'll dive into the AssemblyScript docs more deeply this week and next. I've spent most of my time over the past 10 years in Ruby and JavaScript and have never written anything meaningful in C beyond the most basic intros. clearly this is a gap in my knowledge that I can address. I also expect this gap will be common among 80% of JavaScript developers |
Yeah ideally you shouldn't have to deal with pointers or manual memory management. But perhaps it would be a good idea drafting an article or documentation aimed at JavaScript developers. |
Appears that Regarding Potential enhancements there are to explicitly allow/implement |
@dcodeIO Thanks for the fix! I would say |
@bowenwang1996 I guess console.log(parseFloat('3a')); // => 3
console.log(Number.parseFloat('3a')); // => 3
console.log(Number('3a')); // NaN for |
steps to recreate
i'm not sure where
I32
comes from -- the capital letter makes me think it's a boxed type vs the lower case utility functions documented on the AS website but this is out of my comfort zone.The text was updated successfully, but these errors were encountered: