GNU bug report logs - #17961
"od -c" producing numbers greater than 255 ?

Previous Next

Package: coreutils;

Reported by: Sebastian Pipping <sebastian <at> pipping.org>

Date: Sun, 6 Jul 2014 22:58:04 UTC

Severity: normal

Tags: notabug

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Bernhard Voelker <mail <at> bernhard-voelker.de>
To: Sebastian Pipping <sebastian <at> pipping.org>, 17961 <at> debbugs.gnu.org
Subject: bug#17961: "od -c" producing numbers greater than 255 ?
Date: Mon, 07 Jul 2014 01:55:07 +0200
tag 17961 notabug
close 17961
stop

On 07/06/2014 08:54 PM, Sebastian Pipping wrote:
> I have observed od printing byte values greater than 255 (e.g 302 and
> 303) and wonder if that's a bug and if not what's the idea behind it.
> 
> I'm running coreutils version 8.22.
> 
> My command to re-produce is
> 
>   python3 -c 'for i in range(256): print("%c" % i, end="")' | od -c

Thanks for the bug report.  However, there seems to be some
misunderstanding on your side about what 'od -c' does:
the default output format is to use octal number, which you can
already see in the first line from the printed numbers:

  $ python3 -c 'for i in range(256): print("%c" % i, end="")' | od -c | head -n1
  0000000  \0 001 002 003 004 005 006  \a  \b  \t  \n  \v  \f  \r 016 017

Therefore, od(1) prints up to 377 (octal) in your case - which is 255 decimal:

  $ python3 -c 'print("%o" % 255)'
  377

Have a nice day,
Berny




This bug report was last modified 6 years and 276 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.