Stream: bugs

Topic: U32 to I64 casting


view this post on Zulip Artur Domurad (Oct 24 2024 at 15:59):

When casting U32 to I64 I get a negative number.

Repro:

app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.15.0/SlwdbJ-3GR7uBWQo6zlmYWNYOxnvo8r6YABXD-45UOw.tar.br" }

import pf.Stdout

main =
    numU32 = 2865848396u32
    numI64 = numU32 |> Num.toI64
    Stdout.line! (Inspect.toStr numI64)

The results is:
-1429118900

When using the toInt64Checked version, I get:
(Ok -1429118900)

view this post on Zulip Brendan Hansknecht (Oct 24 2024 at 16:28):

Must be sign extending....interesting

view this post on Zulip Anton (Oct 25 2024 at 09:09):

#7184


Last updated: Jul 06 2025 at 12:14 UTC