by quickthrower2 · 4y ago · 0 comments
So in a static typing context float * int has to be float. Otherwise it is not * it is some other operations (e.g. * composed with floor).
In dynamic typing you could decide the type at runtime. A JS runtime could in theory do that under the hood although semantically it should behave as a float.
Moreover in many cases int * float is an intrinsic, so on the hardware level there is no conversion operation interposed into the operator.
Out of curiosity, what instructions support mixed integer/floating-point operands? I can think of integer-/floating-point-only instructions off the top of my head, and I know I've seen conversion instructions, but not mixed ones. I'm hardly an assembly expert, though, so I wouldn't be surprised if I just wasn't aware of such a thing.
At the end of the day you still need the float multiplied.
[1]: https://play.rust-lang.org/?version=stable&mode=debug&editio...