-
Notifications
You must be signed in to change notification settings - Fork 170
Casting from f64 to u64 does not work #1867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You need to explicitly define the cast. The following should work fine: def f():
x:i16 = i16(3)
y:u16 = u16(x)
print(x, y)
f() |
Thanks @Smit-create, indeed the code you posted works for me in both LLVM and C backends: $ lpython a.py
3 3
$ lpython --backend=c a.py
3 3 @ronnuriel can you please try it out and let us know if that fixes it for you? |
The following works:
but when u64 its not:
ERROR: |
I see, casting from f64 to u64 does not work. I think that's a bug, thanks for reporting it. As a workaround until this gets fixed, this worked for me:
|
x: i16 = i16(3) if x >= 0: I hope it will work. |
Fix error when converting between two different types
for example:
x:i16 = i16(3)
y:u16 = x
Converting i16 to u16.
The text was updated successfully, but these errors were encountered: