factor/basis/math/bits/bits-docs.factor

34 lines
1.4 KiB
Factor
Raw Normal View History

2009-02-20 21:14:54 -05:00
! Copyright (C) 2009 Daniel Ehrenberg
! See http://factorcode.org/license.txt for BSD license.
2009-06-01 23:39:02 -04:00
USING: help.syntax help.markup math sequences ;
2009-02-20 21:14:54 -05:00
IN: math.bits
ABOUT: "math.bits"
ARTICLE: "math.bits" "Number bits virtual sequence"
2009-08-30 07:32:20 -04:00
"The " { $vocab-link "math.bits" } " vocabulary implements a virtual sequence which presents an integer as a sequence of bits, with the first element of the sequence being the least significant bit of the integer."
{ $subsections
bits
<bits>
make-bits
} ;
2009-02-20 21:14:54 -05:00
HELP: bits
{ $class-description "Virtual sequence class of bits of a number. The first bit is the least significant bit. This can be constructed with " { $link <bits> } " or " { $link make-bits } "." } ;
HELP: <bits>
{ $values { "number" integer } { "length" integer } { "bits" bits } }
{ $description "Creates a virtual sequence of bits of a number in little endian order, with the given length." } ;
HELP: make-bits
{ $values { "number" integer } { "bits" bits } }
{ $description "Creates a sequence of bits " { $link bits } " in ascending significance. Throws an error on negative numbers." }
2009-02-20 21:14:54 -05:00
{ $examples
2011-11-23 21:49:33 -05:00
{ $example "USING: math.bits prettyprint arrays ;" "0b1101 make-bits >array ." "{ t f t t }" }
{ $example "USING: math.bits prettyprint arrays ;" "64 make-bits >array ." "{ f f f f t }" }
2009-02-20 21:14:54 -05:00
} ;
2009-06-01 23:39:02 -04:00
HELP: bits>number
2009-06-01 23:39:02 -04:00
{ $values { "seq" sequence } { "number" integer } }
{ $description "Converts a sequence of booleans into a number." } ;