### ----------------------------------------------------
### -- Numeric::Pack
### -- Licenses: Artistic-2.0
### -- Authors: Sam Gillespie
### -- File: README.md
### ----------------------------------------------------
### -- Chunk 2 of 3
ses.



The [Binary::Structured](https://github.com/avuserow/perl6-binary-structured) module appears to be similar to Native::Packing but implemented via a class inheritance interface.



The [P5pack](https://modules.raku.org/dist/P5pack:cpan:ELIZABETH) module is a re-implementation of perl 5's pack subroutine (Raku's pack subroutine is currently experimental in rakudo).



AUTHOR

======



Sam Gillespie <samgwise@gmail.com>



COPYRIGHT AND LICENSE

=====================



Copyright 2016 Sam Gillespie



This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.



FUNCTIONS

=========



### sub pack-float



```perl6

sub pack-float(

    Rat(Cool) $rat,

    ByteOrder :$byte-order = { ... }

) returns Buf

```



Pack a Rat into a single-precision floating-point Buf (e.g. float). Exported via tag :floats. Be aware that Rats and floats are not directly analogous and as such you should expect some variation in the values packed via this method and the original value.



### sub unpack-float



```perl6

sub unpack-float(

    Buf $float-buf,

    ByteOrder :$byte-order = { ... }

) returns Rat

```



Unpack a Buf containing a single-precision floating-point number (float) into a Numeric. Returns a Rat object on a NaN buffer. Exported via tag :floats.



### sub pack-int32



```perl6

sub pack-int32(

    Int(Cool) $int,

    ByteOrder :$byte-order = { ... }

) returns Buf

```



Pack an Int to a 4 byte integer buffer Exported via tag :ints. Be aware that the behaviour of Int values outside the range of a signed 32 bit integer [���2,147,483,648 to 2,147,483,647] is undefined.



### sub unpack-int32



```perl6

sub unpack-int32(

    Buf $int-buf,

    ByteOrder :$byte-order = { ... }

) returns Int

```



Unpack a signed 4 byte integer buffer. Exported via tag :ints.



### sub pack-uint32



```perl6

sub pack-uint32(

    UInt(Cool) $int,

    ByteOrder :$byte-order = { ... }

) returns Buf

```



Pack an Int to a 4 byte unsigned integer buffer Exported via tag :ints. Be aware that the behaviour of Int values outside the range of an unsigned 32 bit integer [0 to 4,294,967,295] is undefined.



### sub unpack-uint32



```perl6

sub unpack-uint32(

    Buf $int-buf,

    ByteOrder :$byte-order = { ... }

) returns Int

```



Unpack an unsigned 4 byte integer buffer. Exported via tag :ints.



### sub pack-double



```perl6

sub pack-double(

    Rat(Cool) $rat,

    ByteOrder :$byte-order = { ... }

) returns Buf

```



Pack a Rat into a double-precision floating-point Buf (e.g. double). Exported via tag :floats. Be aware that Rats and doubles are not directly analogous and as such you should expect some variation in the values packed via this method and the original value.



### sub unpack-double



```perl6

sub unpack-double(

    Buf $double-buf,

    ByteOrder :$byte-order = { ... }

) returns Rat

```



Unpack a Buf containing a double-precision floating-point number (double) into a Numeric. Returns a Rat on NaN buffer. Exported via tag :floats.



### sub pack-int64



```perl6

sub pack-int64(

    Int(Cool) $int,

    ByteOrder :$byte-order = { ... }

) returns Buf

```



Pack an Int to an 8 byte integer buffer Exported via tag :ints. Be aware that the behaviour of Int values outside the range of a signed 64 bit integer [���9,223,372,036,854,775,808 to 9,223,372,036,854,775,807] is undefined.



### sub unpack-int64



```perl6

sub unpack-int64(

    Buf $int-buf,

    ByteOrder :$byte-order = { ... }

) returns Int

```



Unpack a signed 8 byte integer buffer. Exported via tag :ints.



### sub pack-uint64



```perl6

sub pack-uint64(

    UInt(Cool) $int,

    ByteOrder :$byte-order = { ... }

) returns Buf

```



Pack an UInt to an 8 byte unsigned integer buffer Exported via tag :ints. Be aware that the behaviour of Int values outside the range of an unsigned 64bit integer [0 to 18,446,744,073,709,551,615] is undefined.



### sub unpack-uint64



```perl6

sub unpack-uint64(

    Buf $int-buf,

    ByteOrder :$byte-orde