Integer.to_string removing zeros?

Hi i’m trying to do an Integer.to_string integer to binary conversion on something like 00601 but am unable to get a result back that includes the leading zeros. Integer.to_string(00601) returns 601. Is there an Integer function that would help do this?
thank you

I would probably still use to_string but then pipe it into String.pad_leading

2 Likes

There are no integers with leading zeros, so there’s nothing to convert when going from integer to string.

iex(1)> 00601
601
4 Likes

this’ll work, thank you!

Okay; I’ll bite: what’s the context / use case of the leading zeros?

The only thing I can think of are United States postal codes, e.g., “00601” is the postal code for “the Switzerland of Puerto Rico”: