New format/fwrite options

Richard Carlsson <>
Fri Apr 12 00:03:16 CEST 2002


On Thu, 11 Apr 2002, Robert Virding wrote:

> Eshell V2001.09.13  (abort with ^G)
> 1> io:fwrite("~#~n", [4711]).                     %Default is 8
> 8#11147

Great. I agree that 8 is a good default.

> 6> io:fwrite("~b~n", [4711]).                     %Default is 32 bits
> 00000000000000000001001001100111
> ok
> 7> io:fwrite("~b~n", [-4711]).
> 11111111111111111110110110011001

Terrific.

> I think you get the idea.  The only real question I think is if it
> should be the precision field which gives the number of relevant
> bits in ~b/x or the field width.  It might be bit of an overkill to
> have both field width and "precision".  Comments?

Definitely the precision. Field width is a parameter of, well, the field
size (duh), while precision is the "rendering" parameter.

	/Richard


Richard Carlsson ()   (This space intentionally left blank.)
E-mail: 	WWW: http://www.csd.uu.se/~richardc/
 "Having users is like optimization: the wise course is to delay it."
   -- Paul Graham




More information about the erlang-questions mailing list