baseX library using javascript
baseX library is used for mathematical operation on: real numbers of any length, and real number of any base from 2 to 63.
if base is greater than 10, then it uses capital English alphabets
0...9, A=10, B=11, ... Z=35
if base is greater than 36, then it uses small English alphabets
0...9, A=10, B=11, ... Z=35, a=36, b=37, ... z=61
0 1
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 A B C D E F
Number Represented As | Decimal Value Used | Value Is Last Number Of Base | Number Represented As | Decimal Value Used | Value Is Last Number Of Base | Number Represented As | Decimal Value Used | Value Is Last Number Of Base |
---|---|---|---|---|---|---|---|---|
0 | 0 | 1 | L | 21 | 22 | g | 42 | 43 |
1 | 1 | 2 | M | 22 | 23 | h | 43 | 44 |
2 | 2 | 3 | N | 23 | 24 | i | 44 | 45 |
3 | 3 | 4 | O | 24 | 25 | j | 45 | 46 |
4 | 4 | 5 | P | 25 | 26 | k | 46 | 47 |
5 | 5 | 6 | Q | 26 | 27 | l | 47 | 48 |
6 | 6 | 7 | R | 27 | 28 | m | 48 | 49 |
7 | 7 | 8 | S | 28 | 29 | n | 49 | 50 |
8 | 8 | 9 | T | 29 | 30 | o | 50 | 51 |
9 | 9 | 10 | U | 30 | 31 | p | 51 | 52 |
A | 10 | 11 | V | 31 | 32 | q | 52 | 53 |
B | 11 | 12 | W | 32 | 33 | r | 53 | 54 |
C | 12 | 13 | X | 33 | 34 | s | 54 | 55 |
D | 13 | 14 | Y | 34 | 35 | t | 55 | 56 |
E | 14 | 15 | Z | 35 | 36 | u | 56 | 57 |
F | 15 | 16 | a | 36 | 37 | v | 57 | 58 |
G | 16 | 17 | b | 37 | 38 | w | 58 | 59 |
H | 17 | 18 | c | 38 | 39 | x | 59 | 60 |
I | 18 | 19 | d | 39 | 40 | y | 60 | 61 |
J | 19 | 20 | e | 40 | 41 | z | 61 | 62 |
K | 20 | 21 | f | 41 | 42 |
- addition:
BXCNumber addition(BXCNumber num1, BXCNumber num2)
performs signed addition of signed or unsigned addition depending on num1 and num2 and returns resulting BXCNumber
- unsignedAddition:
BXCNumber unsignedAddition(BXCNumber num1, BXCNumber num2)
performs unsigned addition on num1 and num2 and returns resulting BXCNumber
- subtraction:
BXCNumber (BXCNumber num1, BXCNumber num2)
performs signed subtraction. returns BXCNumber resulting after subtracting num2 from num1
- unsignedSubtraction:
BXCNumber unsignedSubtraction(BXCNumber num1, BXCNumber num2)
performs signed subtraction. returns BXCNumber resulting after subtracting num2 from num1
- prepareMultiplicationTable:
BXCNumber[] prepareMultiplicationTable(BXCNumber number)
returns multiplication table of umber passed upto 10 numbers for its base.
for base 10, it will be 10 numbers in the returned array
for base 16, it will be 16 numbers in the returned array
and so on.
- multiplication:
BXCNumber multiplication(BXCNumber num1, BXCNumber num2)
returns BXCNumber resulting after multiplication of num1 and num2. There is no separate operation for signed or unsigned multiplication as of yet.
- division:
BXCNumber division(BXCNumber num1, BXCNumber num2)
returns BXCNumber resulting after division of num1 by num2. There is no separate operation for signed or unsigned division as of yet.
- remainder:
BXCNumber remainder(BXCNumber num1, BXCNumber num2)
returns remainder BXCNumber resulting after division of num1 by num2. There is no separate operation for signed or unsigned remainder.
- unsignedEquate:
Boolean unsignedEquate(BXCNumber num1, BXCNumber num2)
returns true
if num1 and num2 are equal and if their signs are equal, else false.
- signedEquate:
Boolean signedEquate(BXCNumber num1, BXCNumber num2)
returns true
if num1 and num2 are equal without checking for their signs, else false.
- equate:
Boolean equate(BXCNumber num1, BXCNumber num2, Boolean signed)
returns true
if num1 and num2 are equal. whether sign is to be checkd or not is specified in third parameter.
- unsignedMax:
BXCNumber unsignedMax(BXCNumber num1, BXCNumber num2)
returns greater of num1 and num2. does not consider signs of these numbers
- signedMax:
BXCNumber signedMax(BXCNumber num1, BXCNumber num2)
returns greater of num1 and num2. considers signs of these numbers
- max:
BXCNumber max(BXCNumber num1, BXCNumber num2, Boolean signed)
returns greater of num1 and num2. whether signed or not is specified in third parameter
- unsignedMin:
BXCNumber unsignedMin(BXCNumber num1, BXCNumber num2)
returns smaller of num1 and num2. does not consider signs of these numbers
- signedMin:
BXCNumber signedMin(BXCNumber num1, BXCNumber num2)
returns smaller of num1 and num2. considers signs of these numbers
- min:
BXCNumber min(BXCNumber num1, BXCNumber num2, Boolean signed)
returns smaller of num1 and num2. whether signed or not is specified in third parameter
- sum:
BXCNumber sum(BXCNumber[] numbers)
returns summation of all numbers in the array . signed operation.
- multiply:
BXCNumber multiply(BXCNumber[] numbers)
returns multiplication of all numbers in the array . signed operation.
- unsignedMaximum:
number unsignedMaximum(BXCNumber[] numbers)
returns index of maximum of all numbers of the array without checking for sign
- signedMaximum:
number signedMaximum(BXCNumber[] numbers)
returns index of signed maximum of all numbers of the array
- maximum:
number maximum(BXCnumber[] numbers, Boolean signed)
returns index of maximum of all numbers of the array, signed(true
) or not(false
) is specified in third parameter
- unsignedMinimum:
number unsignedMinimum(BXCNumber[] numbers)
returns index of minimum of all numbers of the array without checking for sign
- signedMinimum:
number signedMinimum(BXCNumber[] numbers)
returns index of signed minimum of all numbers of the array
- minimum:
number minimum(BXCNumber[] numbers, Boolean signed)
returns index of minimum of all numbers of the array, signed(true
) or not(false
) is specified in third parameter
- unsignedAreEqual:
Boolean unsignedAreEqual(BXCNumber[] numbers)
returns true
if all numbers in array are equal in value, but not in sign; else returns false
- signedAreEqual:
Boolean signedAreEqual(BXCNumber[] numbers)
returns true
if all numbers in array are equal in value, with their sign; else returns false
- areEqual:
Boolean areEqual(BXCNumber[] numbers, Boolean signed)
returns true
if all numbers in array are equal in value; else returns false. Whether to check for sign or not is specified in second parameter
- shift:
BXCNumber shift(BXCNumber number, Number shiftCount)
returns a number after shifting it to left or right place values, depending on shiftCount
.
positive shiftcount will return leftShift.
negative shiftcount will return rightShift.
shift(10, 0)
wlll return 10
.
- leftShift:
BXCnumber leftShift(BXCNumber number, Number shiftCount)
returns a number that is shifted to left, shiftCount
times.
or simply multiplication of number
with 10
of its base shiftCount
times.
shift(10, 2)
will return BXCNumber with value 1000
.
shift(10.1, 2)
will return BXCNumber with value 1010
.
- rightShift:
BXCnumber rightShift(BXCnumber number, Number shiftCount)
returns a number that is shifted to right, shiftCount
times.
or simply division of number
by 10
of its base shiftCount
times.
check for base before performing operations. base 2 number cannot be added to base 3 number