Added single precision floating point f32#347
Conversation
f32f32
antocuni
left a comment
There was a problem hiding this comment.
@Viriathus1 thank you a lot for this.
It seems mostly complete, but it lacks two things IMHO:
- automatic coercion for
ieee754_div, see my comment below - conversion rules for
f32.
For example, the following two calls should work, but they fail:
def foo(x: f32) -> f32:
return x
foo(1)
foo(1.2)
TypeError: mismatched types
| /tmp/x.spy:7
| foo(1)
| ^ expected `f32`, got `i32`
TypeError: mismatched types
| /tmp/x.spy:7
| foo(1.2)
| |_| expected `f32`, got `f64`
similarly, I should be able to convert from f32 to int if I do it explicitly:
def foo(x: f32) -> int:
return int(x)
TypeError: cannot call objects of type `type`
| /tmp/x.spy:4
| return int(x)
| |_| this is `type`
| return INT32_MIN; | ||
| return (int32_t)x; | ||
| } | ||
|
|
There was a problem hiding this comment.
good choice here! I think that saturating conversion is what happens in rust and C#, so +1 to do the same in SPY
thank you, it looks very good now, merging!
no problem :). |
Added single precision float as type
f32which was mentioned in #305.Slightly different implementation from the other numerical primitives in that all operations call the C backend directly through WASM exported functions as discussed.