Re: Literals, take 2

[email protected] ("John J. Trammell") Thu, 14 Nov 2002 12:57:14 -0600
Newsgroups perl.perl6.documentation
Message-ID <[email protected]>
On Thu, Nov 14, 2002 at 11:02:02AM -0600, Jonathan Scott Duff wrote:
> Now, it would be nice to have a subroutine that, given a number, could
> output in any arbitrary base. Perhaps Perl6 could have a radix()
> subroutine that returns a string representation thusly:
> 
> 	$base = 2;
> 	$number = 13;
> 	print radix($base,$number), "\n";	# outputs 1101
> 
> maybe even with an optional padding so that the above example could be
> output as "00001101".
> 

Perhaps we're just looking at a new printf() format string - %r?
Specifying radix AND padding AND accuracy might be ugly...
"%${rad}.${pad}.${acc}r"?

J