Games::EternalLands::Binary::Float16 - 16-bit floats as used by Eternal Lands
use Games::EternalLands::Binary::Float16 qw(pack_float16 unpack_float16); # Pack to an unsigned short (i.e. a 16-bit unsigned number) $short = pack_float16($float); # Unpack from an unsigned short $float = unpack_float16($short); # Unpack from two bytes of binary data in big-endian order $float = unpack_float16(unpack('n', $data)); # Unpack from binary data in little-endian order at byte offset 40 $float = unpack_float16(unpack('x40v', $data)); ...
This module provides functions to pack and unpack 16-bit floating-point numbers as used in certain game data files by Eternal Lands.
Generally the algorithms should be consistent with the half-precision floating-point format defined by IEEE 754-2008, also know as "half" or "binary16", but this was not tested.
Takes a native floating-point number argument and returns a 16-bit unsigned integer representing the packed half-precision number.
Takes a 16-bit unsigned integer representing a packed half-precision float and returns a native floating-point number.
<coleminor at hush.ai>
Copyright (C) 2012 Cole Minor. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.