Menu

#86 extra space is sprintf('% 3d'

closed
None
2018-12-08
2011-09-23
Anonymous
No

I am running PHP on the Google App Engine. using Quercus.
Because of the space, which contains a space.
$key = '___noise___'.sprintf('% 3d', count($this->noise)+100);
exsample
$this->noise = 23
$key = '___noise___ 123' includes spaces.
So,Not take the correct value
$key = '__noise___'.$text[$pos+11].$text[$pos+12].$text[$pos+13]; became '___noise___ 12'

sprintf('% 3d' -> sprintf('%3d'

Discussion

  • LogMANOriginal

    LogMANOriginal - 2018-12-08
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,10 +1,10 @@
     I am running PHP on the Google App Engine. using Quercus.
     Because of the space, which contains a space. 
    -$key = '___noise___'.sprintf('% 3d', count($this->noise)+100);
    +`$key = '___noise___'.sprintf('% 3d', count($this->noise)+100);`
     exsample 
     $this->noise = 23
    -$key = '___noise___ 123' includes spaces.
    +`$key = '___noise___ 123' includes spaces.`
     So,Not take the correct value
    -$key = '__noise___'.$text[$pos+11].$text[$pos+12].$text[$pos+13];  became  '___noise___ 12'
    +`$key = '__noise___'.$text[$pos+11].$text[$pos+12].$text[$pos+13];  became  '___noise___ 12'`
    
     sprintf('% 3d'  -> sprintf('%3d'
    
    • status: open --> closed
    • assigned_to: LogMANOriginal
     
  • LogMANOriginal

    LogMANOriginal - 2018-12-08

    Closing because the author doesn't exist anymore and the description is not enough to understand the problem (the current implementation works).

    sprintf('% 3d'); vs. sprintf('%3d'); makes no difference if the provided number is smaller than 100. I suppose what is requested here can be solved by sprintf('%03d'); which pads all numbers with zeros to the left.

    Since the current release uses sprintf('% 5d'); this will become sprintf('%05d');

     

Log in to post a comment.