Stream: beginners

Topic: Endianness of Num ser/de functions


view this post on Zulip Qqwy / Marten (Sep 18 2023 at 12:02):

I just stumbled across the functions Num.bytesToU64 and co.
Which endianness is used for these? Big? Little? Whatever is native?

view this post on Zulip Brendan Hansknecht (Sep 18 2023 at 15:16):

I thought we gave those an endianness parameter, given we didn't, must be native

view this post on Zulip Notification Bot (Sep 18 2023 at 16:46):

2 messages were moved here from #beginners > Reserved keywords by Qqwy / Marten.

view this post on Zulip Brendan Hansknecht (Sep 18 2023 at 16:50):

At some point, we decided that we don't want to expose any machine specifics in roc. Tests completely in roc should give the exact same results no matter if they run via wasm in the browser, m1 mac, or some x86 machine. As such, I think this should definitely change to require specifying the endianness. That said, that does lead to a potential perf issue unless the underlying platform exposes endianness to a roc app.

view this post on Zulip Folkert de Vries (Sep 18 2023 at 16:53):

are there any platforms where roc makes sense that have the non-network endianness?

view this post on Zulip Folkert de Vries (Sep 18 2023 at 16:53):

(I always forget which of them that is)

view this post on Zulip Brian Carroll (Sep 18 2023 at 17:02):

TCP/IP is big-endian and most CPUs are little-endian

view this post on Zulip Brian Carroll (Sep 18 2023 at 17:02):

So that's actually the vastly dominant case

view this post on Zulip Folkert de Vries (Sep 18 2023 at 17:23):

sure but the performance should not be a problem: big-endian is always slow, little-endian is native and therefore always faster

view this post on Zulip Richard Feldman (Sep 18 2023 at 19:27):

yeah I think all functions like this should take an explicit endianness :thumbs_up:


Last updated: Jul 06 2025 at 12:14 UTC