Skip to content

Instantly share code, notes, and snippets.

@makamaka
Created September 2, 2010 08:48
Show Gist options
  • Save makamaka/562068 to your computer and use it in GitHub Desktop.
Save makamaka/562068 to your computer and use it in GitHub Desktop.
pack('d>', $double); unpack('d>', $unpacked_double);
# pack, unpackに'>'が使えない場合、
# 下記で等価($doubleの内部表現がリトルエンディアン)
@v = unpack( 'V2', pack( 'd', $double ) );
$packed_double = pack( 'N2', @v[1,0] );
@v = unpack( 'V2', $packed_double );
$double = unpack( 'd', pack( 'N2', @v[1,0] ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment