mirror of
https://github.com/BorysLevytskyi/BitwiseCmd.git
synced 2025-12-10 06:52:05 +01:00
Remove unused methods
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import calc from './calc';
|
||||
import { BitwiseOperationExpression, ScalarValue, BitwiseOperator } from '../expression/expression';
|
||||
import { ScalarValue } from '../expression/expression';
|
||||
import { INT32_MAX_VALUE } from './const';
|
||||
import exp from 'constants';
|
||||
import { asBoundedNumber } from './types';
|
||||
|
||||
describe('calc.flipBit', () => {
|
||||
@@ -45,11 +44,6 @@ describe('calc.numberOfBitsDisplayed', () => {
|
||||
expect(calc.numberOfBitsDisplayed(-INT32_MAX_VALUE)).toBe(32);
|
||||
expect(calc.numberOfBitsDisplayed(-(BigInt(INT32_MAX_VALUE+1)))).toBe(64);
|
||||
});
|
||||
|
||||
|
||||
it('maxNumberOfBitsDisplayed', () => {
|
||||
expect(calc.maxNumberOfBitsDisplayed([1, 2, 3, 10])).toBe(4);
|
||||
});
|
||||
});
|
||||
|
||||
describe('calc.applyTwosComplement', () => {
|
||||
@@ -114,8 +108,8 @@ describe("calc misc", () => {
|
||||
});
|
||||
|
||||
it('binaryRepresentation', () => {
|
||||
expect(calc.binaryRepresentation(asBoundedNumber(2147483647))).toBe("1111111111111111111111111111111");
|
||||
expect(calc.binaryRepresentation(new ScalarValue(2147483647))).toBe("1111111111111111111111111111111");
|
||||
expect(calc.toBinaryString(asBoundedNumber(2147483647))).toBe("1111111111111111111111111111111");
|
||||
expect(calc.toBinaryString(new ScalarValue(2147483647))).toBe("1111111111111111111111111111111");
|
||||
})
|
||||
|
||||
|
||||
|
||||
@@ -20,17 +20,6 @@ export default {
|
||||
return num.toString(2).length;
|
||||
},
|
||||
|
||||
maxNumberOfBitsDisplayed: function (arr: number[]) {
|
||||
|
||||
var counts = [], num;
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
num = arr[i];
|
||||
counts.push(this.numberOfBitsDisplayed(num));
|
||||
}
|
||||
|
||||
return Math.max.apply(null, counts);
|
||||
},
|
||||
|
||||
flipBit: function(num: BoundedNumber | JsNumber, index: number): BoundedNumber {
|
||||
|
||||
num = asBoundedNumber(num);
|
||||
@@ -53,7 +42,7 @@ export default {
|
||||
},
|
||||
|
||||
promoteTo64Bit(number: number) : BoundedNumber {
|
||||
const bin = this.binaryRepresentation(asBoundedNumber(number));
|
||||
const bin = this.toBinaryString(asBoundedNumber(number));
|
||||
return asBoundedNumber(BigInt("0b" + bin));
|
||||
},
|
||||
|
||||
@@ -76,11 +65,7 @@ export default {
|
||||
return flipped.join('') + bin.substring(lastIndex) ;
|
||||
},
|
||||
|
||||
flipAllBits: (bin: string): string => {
|
||||
return bin.split('').map(b => b=="1"?"0":"1").join("");
|
||||
},
|
||||
|
||||
binaryRepresentation(num: BoundedNumber) : string {
|
||||
toBinaryString(num: BoundedNumber) : string {
|
||||
|
||||
const bitSize = num.maxBitSize;
|
||||
const bin = this.abs(num).value.toString(2);
|
||||
@@ -99,7 +84,7 @@ export default {
|
||||
|
||||
const bytes = asIntN(numBytes);
|
||||
|
||||
let bin = this.binaryRepresentation(num).padStart(num.maxBitSize, '0');
|
||||
let bin = this.toBinaryString(num).padStart(num.maxBitSize, '0');
|
||||
|
||||
bin = bin.substring(bytes) + "0".repeat(bytes);
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ const formatter = {
|
||||
var hexVal = calc.abs(num).value.toString(16);
|
||||
return num.value >= 0 ? '0x' + hexVal : '-0x' + hexVal;
|
||||
case 'bin':
|
||||
return calc.binaryRepresentation(num);
|
||||
return calc.toBinaryString(num);
|
||||
case 'dec':
|
||||
return num.value.toString(10);
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user