Stream: beginners

Topic: Num.format


view this post on Zulip Artur Domurad (Dec 12 2023 at 13:26):

In the docs https://www.roc-lang.org/builtins/Num it says:
"To get strings in hexadecimal, octal, or binary format, use Num.format."

But there is no Num.format entry in the docs, and the roc compiler also claims that format is not exposed in the module Num.

Is this a bug? Should this function exist?
Is there another way in roc to print an Int as hexadecimal or binary string?

view this post on Zulip Richard Feldman (Dec 12 2023 at 13:32):

oops yeah let's remove a reference to that from the docs :big_smile:

view this post on Zulip Anton (Dec 12 2023 at 14:46):

#6261

view this post on Zulip Brian Carroll (Dec 14 2023 at 07:53):

Is there another way in roc to print an Int as hexadecimal or binary string?

This question hasn't actually been answered! How do we do this now that Num.format is gone? I don't know myself.

view this post on Zulip Luke Boswell (Dec 14 2023 at 07:58):

There is also a related issue #5213 for parsing floating point numbers. I think it requires a bit of effort for someone to put together a proposal and consider the trade-offs or make a reccomendation.

view this post on Zulip Brendan Hansknecht (Dec 14 2023 at 08:04):

I think this is just a case of having docs for q function that didn't exist, but I think fundamentally we do want the function or some alternative to add the functionality

view this post on Zulip Hannes (Dec 14 2023 at 09:28):

For hexadecimal numbers i wrote this package a while ago, I don't remember if i finished it or not though :sweat_smile:


Last updated: Jul 05 2025 at 12:14 UTC