1 ! Copyright (C) 2009 Daniel Ehrenberg
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: help.syntax help.markup math sequences ;
8 ARTICLE: "math.bits" "Integer virtual sequences"
9 "The " { $vocab-link "math.bits" } " vocabulary implements words that represent a positive integer as a virtual sequence of bits in order of ascending significance, e.g. " { $snippet "{ f f f t }" } " is " { $snippet "8" } "."
18 { $class-description "Tuple representing a number as a virtual sequence of booleans. The first bit is the least significant bit. Constructors are " { $link <bits> } " or " { $link make-bits } "." } ;
21 { $values { "number" integer } { "length" integer } { "bits" bits } }
22 { $description "Constructor for a " { $link bits } " tuple." } ;
25 { $values { "number" integer } { "bits" bits } }
26 { $description "Creates a sequence of " { $link bits } " in ascending significance. Throws an error on negative numbers." }
28 { $example "USING: math.bits prettyprint arrays ;" "0b1101 make-bits >array ." "{ t f t t }" }
29 { $example "USING: math.bits prettyprint arrays ;" "64 make-bits >array ." "{ f f f f f f t }" }
31 { <bits> make-bits } related-words
34 { $values { "seq" sequence } { "number" integer } }
35 { $description "Converts a sequence of booleans in ascending significance into a number." } ;
36 { make-bits bits>number } related-words