Number Formatting Question

Richard Carlsson richardc@REDACTED
Fri Feb 13 10:38:15 CET 2004

On Thu, 12 Feb 2004, Brent Fulgham wrote:

> Is there any way to instruct Erlang to format a number
> with leading zeros?

The general control sequence is `~F.P.PadC' (field width,
precision and pad char). Just change the line

	io:format("~2.16B", [H]),
	io:format("~2.16.0B", [H]),

For example:

  1> io:format("~4.16.0b~n", [42]).


Richard Carlsson (richardc@REDACTED)   (This space intentionally left blank.)
E-mail: Richard.Carlsson@REDACTED	WWW:
 "Having users is like optimization: the wise course is to delay it."
   -- Paul Graham

More information about the erlang-questions mailing list