You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Activity
Smit-create commentedon May 29, 2023
You need to explicitly define the cast. The following should work fine:
certik commentedon May 29, 2023
Thanks @Smit-create, indeed the code you posted works for me in both LLVM and C backends:
@ronnuriel can you please try it out and let us know if that fixes it for you?
ronnuriel commentedon Jun 4, 2023
The following works:
cycles_count: i64
end_cycle: i64 = i64(100)
start_cycle: i64 = i64(4)
num_iters: i64 = i64(4)
but when u64 its not:
cycles_count: u64 #THIS LINE
end_cycle: i64 = i64(100)
start_cycle: i64 = i64(4)
num_iters: i64 = i64(4)
ERROR:
|
181 | cycles_count = u64((end_cycle - start_cycle) / num_iters)
| ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch ('u64' and 'f64')
certik commentedon Jun 4, 2023
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:
[-]converting between different types - C backend [/-][+]Casting from f64 to u64 does not work[/+]Darshan4852 commentedon Jun 9, 2023
x: i16 = i16(3)
y: u16
if x >= 0:
y = u16(x)
else:
y = u16(2 ** 16 - 1)
I hope it will work.