[PATCH 5/9] vsprintf: add %w and %w support to print unit

Uwe Kleine-König u.kleine-koenig at pengutronix.de
Thu Sep 2 13:54:32 EDT 2010


On Thu, Sep 02, 2010 at 05:54:21PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 17:32 Thu 02 Sep     , Uwe Kleine-König wrote:
> > Hello,
> > 
> > On Thu, Sep 02, 2010 at 05:29:33PM +0200, Uwe Kleine-König wrote:
> > > Hello Jean-Christophe,
> > > 
> > > On Thu, Sep 02, 2010 at 04:10:20PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > Show a '%w' or %W thing.
> > > > This will show a frequency or byte at format xxx[.xxx] [ kMG]
> > > > the precision can not excess the base kMG of the current unit
> > > > otherwise it will be automatically reduce
> > > > if no precision is specified and there is rest we will use a default
> > > > precision of 3 as 66.667 M
> > > > base will be typically 1000 for Hz or B and 1024 for iB
> > > I see this used e.g. as:
> > > 
> > > 	printk("%WiB", somevalue)
> > > 
> > > right?  hmm, what if somevalue is say 5?  If I understand correctly the
> > > output then is: "5 iB".
> > [I forgot to complete this, sorry]
> > 
> > "5 iB" looks ugly, doesn't it?  Do you care enough to fix that?
> After it's everyone preference
> 
> What do you think of
> 100MHz
> 100 MHz
> 
> 1 Hz
> 1Hz
> 
> 100 MiB
> 100MiB
> 
> 1iB
> 1 iB
> 
> so which one?
IMHO iB doesn't make sense.  What should be the difference to a plain B?

And if "%WiB" yields 100MiB for 100*1024**2, it should yield 5B for 5
but neither "5 iB" nor "5iB" nor "5 B".

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |



More information about the barebox mailing list