]> gitweb.factorcode.org Git - factor.git/blob - core/io/binary.facts
571df4924377617abe5fc60ea54aa98c933ef997
[factor.git] / core / io / binary.facts
1 USING: help io ;
2
3 HELP: be>
4 { $values { "seq" "a sequence of bytes" } { "x" "a non-negative integer" } }
5 { $description "Converts a sequence of bytes in big endian order into an unsigned integer." } ;
6
7 HELP: le>
8 { $values { "seq" "a sequence of bytes" } { "x" "a non-negative integer" } }
9 { $description "Converts a sequence of bytes in little endian order into an unsigned integer." } ;
10
11 HELP: nth-byte
12 { $values { "x" "an integer" } { "n" "a non-negative integer" } { "b" "a byte" } }
13 { $description "Outputs the " { $snippet "n" } "th least significant byte of the sign-extended 2's complement representation of " { $snippet "x" } "." } ;
14
15 HELP: >le
16 { $values { "x" "an integer" } { "n" "a non-negative integer" } { "str" "a string" } }
17 { $description "Converts an integer " { $snippet "x" } " into a string of " { $snippet "n" } " bytes in little endian order. Truncation will occur if the integer is not in the range " { $snippet "[-2^(8n),2^(8n))" } "." } ;
18
19 HELP: >be
20 { $values { "x" "an integer" } { "n" "a non-negative integer" } { "str" "a string" } }
21 { $description "Converts an integer " { $snippet "x" } " into a string of " { $snippet "n" } " bytes in big endian order. Truncation will occur if the integer is not in the range " { $snippet "[-2^(8n),2^(8n))" } "." } ;