thesis / endian
Library for encoding and decoding numbers in either big-endian or little-endian order.
Fund package maintenance!
www.tinkoff.ru/cf/5MqZQas2dk7
Installs: 19 482
Dependents: 4
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/thesis/endian
Requires
- php: ^8.4
- ext-bcmath: *
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.8.2
- ergebnis/composer-normalize: ^2.48.2
- phpunit/phpunit: ^10.5.58
- symfony/var-dumper: ^7.3
README
Installation
composer require thesis/endian
Read/write in any byte order:
- In
network(big endian) byte order.
use Thesis\Endian; echo Endian\Order::network->unpackInt32( Endian\Order::network->packInt32(-200), ); // -200
- In
big endianbyte order.
use Thesis\Endian; echo Endian\Order::big->unpackInt8( Endian\Order::big->packInt8(17), ); // 17
- In
little endianbyte order.
use Thesis\Endian; echo Endian\Order::little->unpackFloat( Endian\Order::little->packFloat(2.2), ); // 2.2
- In
native endianbyte order.
use Thesis\Endian; use BcMath\Number; echo Endian\Order::native() ->unpackInt64( Endian\Order::native()->packInt64(new Number('9223372036854775807')), ) ->value; // 9223372036854775807
Supported types:
-
int8 -
uint8 -
int16 -
uint16 -
int32 -
uint32 -
int64 -
uint64 -
float -
double