funary
Arbitrary precision binary operations library for Javascript.
Table of contents
- Install
- Logic gates
- Bitwise operations & bit shifts
- Big endian operations
- Little endian operations
- Full & Half adders
- General conversions
- Other operations
- Related projects
Install
npm install funary
var funary = ;
Clientside
Logic gates
The library has XOR,AND,OR,NAND,XNOR, and NOR logic gates.
var funary = ; funarygates //0funarygates //1funarygates //1funarygates //0funarygates //1funarygates //0
Bitwise operations & bit shifts
Bitwise operations and bit shifts for bit manipulation.
var funary = ;//Bitwise operations. Similar selection to gates. AND,OR , ... etc.funarybitwise //[0,0,0,0,0,1,0,1,0,1]// 0101010111//& 1000111101//-------------// 0000010101funarybitwise //[1,1,0,1,1,1,1,1,1,1]// 0101010111//| 1000111101//-------------// 1101111111funarybitwise //[0,0,1,0,0,1,0,1,0,1]// 0101010111//XNOR 1000111101//---------------// 0010010101 //Bit shiftsfunaryleft0010112 //[1,0,1,1,0,0]funaryright0010112 //[0,0,0,0,1,0]
Big endian operations
Operations done in Big endian. Most significant digit in smallest address
Big endian arithmetic
Arithmetic operations. Any two arrays with any length.
var funary = ;//Additionfunarybig //[1,1,1,0,0,1,0,1,0,0]// 0101010111//+ 1000111101//------------// 1110010100 //Multiplicationfunarybig //[1,0,0,1,1,0,1,1,1,0,1,0,0,1,1,1,1]// 101011001//X 11100111//-------------------// 10011011101001111
Big endian encoders & decoders
Encode and decode arrays of any size.
var funary = ;//Encodersfunarybig //[0, 0, 0]funarybig //[0, 1, 0]funarybig //[0, 0, 1] funarybig //[0, 0, 1, 0]funarybig //[1, 1, 1, 0] //Decodersfunarybig //[0, 0, 0, 0, 0, 0, 0, 1]funarybig //[0, 0, 0, 0, 0, 0, 1, 0]funarybig //[0, 0, 0, 0, 0, 1, 0, 0] funarybig //[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]funarybig //[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Big endian multiplexers & demultiplexers
var funary = ;//Multiplexing// selectors inputsfunarybig //0funarybig //1funarybig //0funarybig //1 funarybig //0funarybig //1 //Demultiplexing// selectors inputsfunarybig //[0, 0, 0, 0]funarybig //[0, 0, 0, 1]funarybig //[0, 0, 0, 0]funarybig //[0, 1, 0, 0] funarybig //[0, 0, 0, 0, 0, 0, 1, 0]funarybig //[0, 0, 0, 0, 0, 0, 0, 0]
Big endian conversions
Conversions between formats
var funary = ;//Decimal to binaryfunarybig //[1, 1, 0, 0]//Binary to decimalfunarybig //13
Little endian operations
Operations done in Little endian. Most significant digit in largest address
Little endian arithmetic
Arithmetic operations. Any two arrays with any length.
var funary = ;//Additionfunarylittle //[1,1,0,1,1,0,0,1,0,1,1]// 0101010111//+ 1000111101//-------------// 11011001011 //Multiplicationfunarylittle //[1,1,0,1,0,1,1,0,1,0,0,0,1]// 111010101//X 1011//---------------// 1101011010001
Little endian encoders & decoders
Encode and decode arrays of any size.
var funary = ;//Encodersfunarylittle //[0,0,0]funarylittle //[1,0,0]funarylittle //[0,1,0] funarylittle //[0,1,0,1]funarylittle //[1,1,0,1] //Decodersfunarylittle //[1, 0, 0, 0, 0, 0, 0, 0]funarylittle //[0, 1, 0, 0, 0, 0, 0, 0]funarylittle //[0, 0, 1, 0, 0, 0, 0, 0] funarylittle //[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]funarylittle //[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]
Little endian multiplexers & demultiplexers
var funary = ;//Multiplexing// selectors inputsfunarylittle //0funarylittle //1funarylittle //0funarylittle //1 funarylittle //0funarylittle //1 //Demultiplexing// selectors inputsfunarylittle //[0, 0, 0, 0]funarylittle //[1, 0, 0, 0]funarylittle //[0, 0, 0, 0]funarylittle //[0, 0, 1, 0] funarylittle //[0, 0, 0, 0, 1, 0, 0, 0]funarylittle //[0, 0, 0, 0, 0, 0, 0, 0]
Little endian conversions
Conversions between formats
var funary = ; //Decimal to binaryfunarylittle //[0, 0, 1, 1]//Binary to decimalfunarylittle //23
Full & Half adders
var funary = ; //Little endian by defaultfunary //[1,1]funary //[0,1]funary //[0,1]funary //[1,0]funary //[1,0]funary //[0,1]
General conversions
var funary = ;//Array of bits to stringfunary //"11010111100"//String to array of bitsfunary //[0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1]//Convert bool array to binaryfunary //[0,0,1,1,0]//Convert binary array to boolfunary //[false,true,false,true,false,false]
Other operations
var funary = ; funary //0funary //1funary //[1,0,0,1,1,0,0,0]//Truncationfunary //[1, 1, 1, 0]funary //[0, 1, 0, 1, 0]//Number of onesfunary //5//Combinationsfunary //[[1,1,1],[0,1,1],[1,0,1],[0,0,1],[1,1,0],[0,1,0],[1,0,0],[0,0,0]]//Zerosfunary //[0,0,0,0]//Add zerosfunary //[1,0,0,0]//UNshift zerosfunary //[0,0,0,1]
Related projects
Digital Logic Circuit Simulation library. Create and simulate high level integrated circuits. Depends on funary.