Type conversion between basic types

I seem to struggle to figure out how to convert basic types. There are to_int() functions but converting to bool or to float from int or similar stumps me. How is it supposed to work? The code let a: Int32 = 5 let b: Float32 = Float32(a) gives me "cannot construct 'SIMD[f32, 1]' from 'SIMD[si32, 1]' value in 'let' initializer
2 Replies
sora
sora12mo ago
You will need to use let b = a.cast[DType.float32]() in this case. And to convert something to Int, I will suggest you to use int(...).
ModularBot
ModularBot12mo ago
Congrats @sora, you just advanced to level 10!
Want results from more Discord servers?
Add your server