Index: src/RawConverter.cc =================================================================== RCS file: /afs/psi.ch/user/z/zimoch/.cvsroot/StreamDevice2/src/RawConverter.cc,v retrieving revision 1.6 diff -u -r1.6 RawConverter.cc --- src/RawConverter.cc 10 Jul 2006 11:08:22 -0000 1.6 +++ src/RawConverter.cc 21 Nov 2007 15:37:51 -0000 @@ -54,7 +54,16 @@ value >>= 8; width--; } - byte = (byte & 0x80) ? 0xFF : 0x00; // fill with sign + if (format.flags & zero_flag) + { + // fill with zero + byte = 0; + } + else + { + // fill with sign + byte = (byte & 0x80) ? 0xFF : 0x00; + } while (width--) { output.append(byte); @@ -62,8 +71,17 @@ } else // msb first (big endian) { - byte = ((value >> (8 * (prec-1))) & 0x80) ? 0xFF : 0x00; - while (width > prec) // fill with sign + if (format.flags & zero_flag) + { + // fill with zero + byte = 0; + } + else + { + // fill with sign + byte = ((value >> (8 * (prec-1))) & 0x80) ? 0xFF : 0x00; + } + while (width > prec) { output.append(byte); width--; @@ -98,14 +116,32 @@ } if (width == 0) { - val |= ((signed char) input[length++]) << shift; + if (format.flags & zero_flag) + { + // fill with zero + val |= ((unsigned char) input[length++]) << shift; + } + else + { + // fill with sign + val |= ((signed char) input[length++]) << shift; + } } length += width; // ignore upper bytes not fitting in long } else { - // big endian (sign extended)*/ - val = (signed char) input[length++]; + // big endian */ + if (format.flags & zero_flag) + { + // fill with zero + val = (unsigned char) input[length++]; + } + else + { + // fill with sign + val = (signed char) input[length++]; + } while (--width) { val <<= 8; Index: doc/formats.html =================================================================== RCS file: /afs/psi.ch/user/z/zimoch/.cvsroot/StreamDevice2/doc/formats.html,v retrieving revision 1.12 diff -u -r1.12 formats.html --- doc/formats.html 3 Oct 2007 08:18:08 -0000 1.12 +++ doc/formats.html 5 Feb 2008 08:42:50 -0000 @@ -264,23 +264,28 @@

9. Raw LONG Converter (%r)

The raw converter does not really "convert". -A signed integer value is written or read in the internal +A signed or unsigned integer value is written or read in the internal (usually two's complement) representation of the computer. The normal byte order is big endian, i.e. most significant byte first. With the # flag, the byte order is changed to little endian, i.e. least significant byte first. +With the 0 flag, the value is unsigned, otherwise signed.

In output, the width least significant bytes of the value are written. If width is larger than the size of a long, -the value is sign extended. +the value is sign extended or zero extended, depending on the +0 flag.

In input, width bytes are read and put into the value. -If width is longer than the size of a long, only +If width is larger than the size of a long, only the least significant bytes are used. +If width is smaller than the size of a long, +the value is sign extended or zero extended, depending on the +0 flag.