Stream: beginners

Topic: How to print a number as binary?


view this post on Zulip notramo (Oct 02 2026 at 21:03):

Given an integer like 255, how to print it as 1111_1111 or similar? Is there some builtin, or need to write my own?

view this post on Zulip notramo (Oct 02 2026 at 21:04):

Many languages allow providing a base to to_str, but I don't see anything similar in Roc.

view this post on Zulip Luke Boswell (Oct 02 2026 at 21:10):

Are there any open issues about number formatting? I feel like weve discussed this but I dont remember which way it went.

view this post on Zulip notramo (Oct 02 2026 at 21:12):

I could not find.

view this post on Zulip notramo (Oct 02 2026 at 21:12):

Found one about parsing:

view this post on Zulip notramo (Oct 02 2026 at 21:12):

https://github.com/roc-lang/roc/issues/4172

view this post on Zulip notramo (Oct 02 2026 at 21:12):

But none about printing.


Last updated: Oct 15 2026 at 17:56 UTC