/** * Return a signed long read from the data. * * @param * int the offset into the data. An offset of zero will * return the first long available in the current allowed window. * The last valid offset is equal to {@link getSize()}-4. Invalid * offsets will result in a {@link PelDataWindowOffsetException} * being thrown. * * @return int the signed long found at offset. */ public function getSLong($o = 0) { /* * Validate the offset+3 to see if we can safely get four bytes * --- this throws an exception if offset is out of range. */ $this->validateOffset($o); $this->validateOffset($o + 3); /* Translate the offset into an offset into the data. */ $o += $this->start; /* Return a signed long. */ return PelConvert::bytesToSLong($this->data, $o, $this->order); }
function testSLongBig() { $o = PelConvert::BIG_ENDIAN; $this->assertEqual(PelConvert::bytesToSLong($this->bytes, 0, $o), 0x0 << 24 | 0x0 << 16 | 0x0 << 8 | 0x0); $this->assertEqual(PelConvert::bytesToSLong($this->bytes, 1, $o), 0x0 << 24 | 0x0 << 16 | 0x0 << 8 | 0x1); $this->assertEqual(PelConvert::bytesToSLong($this->bytes, 2, $o), 0x0 << 24 | 0x0 << 16 | 0x1 << 8 | 0x23); $this->assertEqual(PelConvert::bytesToSLong($this->bytes, 3, $o), 0x0 << 24 | 0x1 << 16 | 0x23 << 8 | 0x45); $this->assertEqual(PelConvert::bytesToSLong($this->bytes, 4, $o), 0x1 << 24 | 0x23 << 16 | 0x45 << 8 | 0x67); $this->assertEqual(PelConvert::bytesToSLong($this->bytes, 5, $o), 0x23 << 24 | 0x45 << 16 | 0x67 << 8 | 0x89); $this->assertEqual(PelConvert::bytesToSLong($this->bytes, 6, $o), 0x45 << 24 | 0x67 << 16 | 0x89 << 8 | 0xab); $this->assertEqual(PelConvert::bytesToSLong($this->bytes, 7, $o), 0x67 << 24 | 0x89 << 16 | 0xab << 8 | 0xcd); $this->assertEqual(PelConvert::bytesToSLong($this->bytes, 8, $o), 0x89 << 24 | 0xab << 16 | 0xcd << 8 | 0xef); $this->assertEqual(PelConvert::bytesToSLong($this->bytes, 9, $o), 0xab << 24 | 0xcd << 16 | 0xef << 8 | 0xff); $this->assertEqual(PelConvert::bytesToSLong($this->bytes, 10, $o), 0xcd << 24 | 0xef << 16 | 0xff << 8 | 0xff); $this->assertEqual(PelConvert::bytesToSLong($this->bytes, 11, $o), 0xef << 24 | 0xff << 16 | 0xff << 8 | 0xff); $this->assertEqual(PelConvert::bytesToSLong($this->bytes, 12, $o), 0xff << 24 | 0xff << 16 | 0xff << 8 | 0xff); }