Please select what you are reporting on:
Verse
What Type of Bug are you experiencing?
Verse
Summary
As far as I know, the only way to currently cast an Int to a Float is by multiplication. The user should be very careful not to do the casting as part of a division, otherwise, the product is returned instead!
Steps to Reproduce
Run this code:
Int1 : int = 3
Int2 : int = 4
WrongResult : float = 1.0*Int1 / 1.0*Int2 # = 12 (!?)
CorrectResult : float = (1.0*Int1) / (1.0*Int2) # = 0.75
Expected Result
I would expect the WrongResult
expression to either typecast as I had expected and yield the expected value (0.75), or alternatively not compile, rather than returning a (mathematically) wrong result.
Observed Result
When typecasting as part of a calculation (as above), 3/4 = 12, which can lead to some pretty hard-to-debug issues.
Platform(s)
Windows 11, UEFN 29.30