[ dup byte-array? ] [ f ] if
] 2dip if ; inline
+: 1be> ( bytes -- x )
+ big-endian [ uint8_t deref ] [ 1 n-be> ] if-endian ;
+
: 2be> ( bytes -- x )
big-endian [ uint16_t deref ] [ 2 n-be> ] if-endian ;
: 8be> ( bytes -- x )
big-endian [ uint64_t deref ] [ 8 n-be> ] if-endian ;
+: 1le> ( bytes -- x )
+ little-endian [ uint8_t deref ] [ 1 n-le> ] if-endian ;
+
: 2le> ( bytes -- x )
little-endian [ uint16_t deref ] [ 2 n-le> ] if-endian ;
: be> ( bytes -- x )
dup length {
+ { 1 [ 1be> ] }
{ 2 [ 2be> ] }
{ 4 [ 4be> ] }
{ 8 [ 8be> ] }
: le> ( bytes -- x )
dup length {
+ { 1 [ 1le> ] }
{ 2 [ 2le> ] }
{ 4 [ 4le> ] }
{ 8 [ 8le> ] }
: signed-be> ( bytes -- x )
big-endian [
dup length {
+ { 1 [ int8_t deref ] }
{ 2 [ int16_t deref ] }
{ 4 [ int32_t deref ] }
{ 8 [ int64_t deref ] }
: signed-le> ( bytes -- x )
little-endian [
dup length {
+ { 1 [ int8_t deref ] }
{ 2 [ int16_t deref ] }
{ 4 [ int32_t deref ] }
{ 8 [ int64_t deref ] }