i have one function but i am not getting what is it doing.
Below is my function
// My function gets two parameters lat and long
public function generate_peano1($lat, $lon)
{
$lat = (($lat + 90.0)/180.0 * 32767) + 16384;
$lon = ($lon + 180.0)/360.0 * 65535;
$lat_16 = $lat&0x0000FFFF; // Not getting what is here.
$lon_16 = $lon&0x0000FFFF; // Not getting what is here.
$peano = self::derive_peano_32($lat_16, $lon_16);
return $peano;
}
Thanks
Avinash
The
&operator is the bitwise AND operator.0x0000FFFFrepresents 16 unset bits (zeroes) followed by 16 set bits (ones) in hexadecimal.$lat & 0x0000FFFFwill then give you the 16 least significant bits (on a little endian machine, which is the most common architecture) of $lat.As to why is that needed here it depends on what does
self::derive_peano_32()do. I’d imagine it takes two 16 bit values and concatenate them somehow so they fit in a regular 32 bit integer.