コード例 #1
0
 public void Initialization_TEST()
 {
     BinInt bin = new BinInt("", 8);
     Assert.AreEqual("00000000",bin.StoredInput);
     bin = new BinInt("ABC", 8);
     Assert.AreEqual("00000000", bin.StoredInput);
 }
コード例 #2
0
        public BinInt Convert(DecInt input)
        {
            long toBeConverted = input.StoredNumber;
            int bitNumber = input.allowedNumberOfBits;
            string result = FromDecIntPos(toBeConverted, bitNumber);
            BinInt output = new BinInt(result, bitNumber);

            return output;
        }
コード例 #3
0
        public DecInt Convert(BinInt input)
        {
            int size = input.allowedNumberOfBits;
            int convertFromBase = 2;
            string toBeConverted = input.StoredInput;
            uint result = ToDecFromIntPos(toBeConverted, convertFromBase);
            DecInt output = new DecInt(result,size);

            return output;
        }
コード例 #4
0
 public void ConvertDec_TEST()
 {
     dec.StoredNumber = 25;
     bin = converter.Convert(dec);
     Assert.AreEqual(8, bin.allowedNumberOfBits);
     Assert.AreEqual("00011001", bin.StoredInput);
     dec.StoredNumber = 16;
     bin = converter.Convert(dec);
     Assert.AreEqual("00010000", bin.StoredInput);
     dec.StoredNumber = 1;
     bin = converter.Convert(dec);
     Assert.AreEqual("00000001", bin.StoredInput);
     dec.StoredNumber = 14;
     bin = converter.Convert(dec);
     Assert.AreEqual("00001110", bin.StoredInput);
     dec.StoredNumber = 5;
     bin = converter.Convert(dec);
     Assert.AreEqual("00000101", bin.StoredInput);
     dec.StoredNumber = 41;
     bin = converter.Convert(dec);
     Assert.AreEqual("00101001", bin.StoredInput);
 }
コード例 #5
0
 public void Setup()
 {
     converter = new ConverterToDec();
     bin = new BinInt();
     uBin = new UnfixedBinInteger();
     hex = new UnfixedPowOfTwoInteger(PowOfTwoBases.BASE_SIXTEEN);
     oct = new UnfixedPowOfTwoInteger(PowOfTwoBases.BASE_EIGHT);
 }
コード例 #6
0
        //fix this
        public SignedBinInt Negate(BinInt unsigned)
        {
            //string toBeNegated = unsigned.StoredInput;
            //string result = this.NegateBin(toBeNegated);

            //SignedBinInt output = new SignedBinInt(input: result, size: unsigned.allowedNumberOfBits);

            //return output;
            throw new NotImplementedException();
        }