コード例 #1
0
        public bool IsComplCodeMinus(ComplementCode code)
        {
            ComplementCode cNull = new ComplementCode(code.ToString().Length, new String('0', code.ToString().Length));

            if (code < cNull)
                return true;
            else
                return false;
        }
コード例 #2
0
        public string GetSignMagnitude(ComplementCode code)
        {
            ComplementCode resultingCode = new ComplementCode(code);

            if (IsComplCodeMinus(code))
                resultingCode = -code;

            return resultingCode.ToString();
        }
コード例 #3
0
        public string Convert(string number)
        {
            NumberManipulation.CheckNumberCorrectness(number, NumberManipulation.cDecNumberSystem);

            number = Converter.ConvertFromDecNumber(new ToSTDConverter(2), number);

            ComplementCode complCodeRepresentation = new ComplementCode(mBitCapacity,
                NumberManipulation.GetCommonNumberMantissa(number));

            if (NumberManipulation.IsMinusNumber(number))
                complCodeRepresentation = -complCodeRepresentation;

            return complCodeRepresentation.ToString();
        }