Пример #1
0
 /**
  * Return a signed byte from the data.
  *
  * @param
  *            int the offset into the data. An offset of zero will
  *            return the first byte in the current allowed window. The last
  *            valid offset is equal to {@link getSize()}-1. Invalid offsets
  *            will result in a {@link PelDataWindowOffsetException} being
  *            thrown.
  *
  * @return int the signed byte found at offset.
  */
 public function getSByte($o = 0)
 {
     /*
      * Validate the offset --- this throws an exception if offset is
      * out of range.
      */
     $this->validateOffset($o);
     /* Translate the offset into an offset into the data. */
     $o += $this->start;
     /* Return a signed byte. */
     return PelConvert::bytesToSByte($this->data, $o);
 }
Пример #2
0
 function testSByte()
 {
     $this->assertEqual(PelConvert::bytesToSByte($this->bytes, 0), 0);
     $this->assertEqual(PelConvert::bytesToSByte($this->bytes, 1), 0);
     $this->assertEqual(PelConvert::bytesToSByte($this->bytes, 2), 0);
     $this->assertEqual(PelConvert::bytesToSByte($this->bytes, 3), 0);
     $this->assertEqual(PelConvert::bytesToSByte($this->bytes, 4), 1);
     $this->assertEqual(PelConvert::bytesToSByte($this->bytes, 5), 35);
     $this->assertEqual(PelConvert::bytesToSByte($this->bytes, 6), 69);
     $this->assertEqual(PelConvert::bytesToSByte($this->bytes, 7), 103);
     $this->assertEqual(PelConvert::bytesToSByte($this->bytes, 8), -119);
     $this->assertEqual(PelConvert::bytesToSByte($this->bytes, 9), -85);
     $this->assertEqual(PelConvert::bytesToSByte($this->bytes, 10), -51);
     $this->assertEqual(PelConvert::bytesToSByte($this->bytes, 11), -17);
     $this->assertEqual(PelConvert::bytesToSByte($this->bytes, 12), -1);
     $this->assertEqual(PelConvert::bytesToSByte($this->bytes, 13), -1);
     $this->assertEqual(PelConvert::bytesToSByte($this->bytes, 14), -1);
     $this->assertEqual(PelConvert::bytesToSByte($this->bytes, 15), -1);
 }