Esempio n. 1
0
	/**
	 * writeDouble takes a float as the input and writes it to the output stream.
	 * Then if the system is big-endian, it reverses the bytes order because all
	 * doubles passed via remoting are passed little-endian.
	 *
	 * @param double $d The double to add to the output buffer
	 */
	protected function writeDouble($d) {
		$b = pack("d", $d); // pack the bytes
		if (AmfUtil::isSystemBigEndian()) { // if we are a big-endian processor
			$r = strrev($b);
		} else { // add the bytes to the output
			$r = $b;
		}

		$this->outBuffer .= $r;
	}
Esempio n. 2
0
	/**
	 * readDouble reads the floating point value from the bytes stream and properly orders
	 * the bytes depending on the system architecture.
	 *
	 * @return float The floating point value of the next 8 bytes
	 */
	protected function readDouble(){
		$bytes = substr($this->rawData, $this->currentByte, 8);
		$this->currentByte += 8;
		if (AmfUtil::isSystemBigEndian()){
			$bytes = strrev($bytes);
		}
		$zz = unpack("dflt", $bytes); // unpack the bytes
		return $zz['flt']; // return the number from the associative array
	}