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" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-06 17:45:30 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								ARTICLE: "math.bits"  "Integer virtual sequences" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"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"  } "."  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    bits
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    <bits>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    make-bits
							 
						 
					
						
							
								
									
										
										
										
											2014-06-06 17:45:30 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    bits>number
							 
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
									
										
										
										
											2009-02-20 21:14:54 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  bits  
						 
					
						
							
								
									
										
										
										
											2014-06-06 17:45:30 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $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 } "."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2009-02-20 21:14:54 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  <bits>  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "number"  integer  } { "length"  integer  } { "bits"  bits } }
							 
						 
					
						
							
								
									
										
										
										
											2014-06-06 17:45:30 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Constructor for a "  { $link bits } " tuple."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2009-02-20 21:14:54 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  make-bits  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "number"  integer  } { "bits"  bits } }
							 
						 
					
						
							
								
									
										
										
										
											2014-06-06 17:45:30 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Creates a sequence of "  { $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 }"  }
							 
						 
					
						
							
								
									
										
										
										
											2014-06-06 17:45:30 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    { $example "USING: math.bits prettyprint arrays ;"  "64 make-bits >array ."  "{ f f f f f f t }"  }
							 
						 
					
						
							
								
									
										
										
										
											2009-02-20 21:14:54 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
									
										
										
										
											2014-06-06 17:45:30 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ <bits> make-bits } related-words
							 
						 
					
						
							
								
									
										
										
										
											2009-06-01 23:39:02 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-06 17:24:39 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HELP:  bits>number  
						 
					
						
							
								
									
										
										
										
											2009-06-01 23:39:02 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "seq"  sequence  } { "number"  integer  } }
							 
						 
					
						
							
								
									
										
										
										
											2014-06-06 17:45:30 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Converts a sequence of booleans in ascending significance into a number."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ make-bits bits>number } related-words