コード例 #1
0
		private static void TestNormalize_09()
		{
			bool _okTest1, _okTest2, _okTest3, _okTest4, _okTest5, _okTest6, _okTest7, _okTest8, _okTest9, _okTest10, _okTest11, _okTest12, _okTest13, _okTest14, _okTest15;

			{
				FloatingPointBigScale _number = new FloatingPointBigScale(107.34M, 5);
				FloatingPointBigScale _normalizedNumber = _number.Normalize_09();
				FloatingPointBigScale _normalizedNumberMustBe = new FloatingPointBigScale(1.0734M, 7);
				_okTest1 = _normalizedNumberMustBe.SameInFormat(_normalizedNumber);
			}

			{
				FloatingPointBigScale _number = new FloatingPointBigScale(1.0734M, 5);
				FloatingPointBigScale _normalizedNumber = _number.Normalize_09();
				FloatingPointBigScale _normalizedNumberMustBe = new FloatingPointBigScale(1.0734M, 5);
				_okTest2 = _normalizedNumberMustBe.SameInFormat(_normalizedNumber);
			}

			{
				FloatingPointBigScale _number = new FloatingPointBigScale(0.0010734M, 5);
				FloatingPointBigScale _normalizedNumber = _number.Normalize_09();
				FloatingPointBigScale _normalizedNumberMustBe = new FloatingPointBigScale(1.0734M, 2);
				_okTest3 = _normalizedNumberMustBe.SameInFormat(_normalizedNumber);
			}
			{
				FloatingPointBigScale _number = new FloatingPointBigScale(-107.34M, 5);
				FloatingPointBigScale _normalizedNumber = _number.Normalize_09();
				FloatingPointBigScale _normalizedNumberMustBe = new FloatingPointBigScale(-1.0734M, 7);
				_okTest4 = _normalizedNumberMustBe.SameInFormat(_normalizedNumber);
			}
			{
				FloatingPointBigScale _number = new FloatingPointBigScale(-1.0734M, 5);
				FloatingPointBigScale _normalizedNumber = _number.Normalize_09();
				FloatingPointBigScale _normalizedNumberMustBe = new FloatingPointBigScale(-1.0734M, 5);
				_okTest5 = _normalizedNumberMustBe.SameInFormat(_normalizedNumber);
			}
			{
				FloatingPointBigScale _number = new FloatingPointBigScale(-0.0010734M, 5);
				FloatingPointBigScale _normalizedNumber = _number.Normalize_09();
				FloatingPointBigScale _normalizedNumberMustBe = new FloatingPointBigScale(-1.0734M, 2);
				_okTest6 = _normalizedNumberMustBe.SameInFormat(_normalizedNumber);
			}
			{
				FloatingPointBigScale _number = new FloatingPointBigScale(107.34M, -5);
				FloatingPointBigScale _normalizedNumber = _number.Normalize_09();
				FloatingPointBigScale _normalizedNumberMustBe = new FloatingPointBigScale(1.0734M, -3);
				_okTest7 = _normalizedNumberMustBe.SameInFormat(_normalizedNumber);
			}
			{
				FloatingPointBigScale _number = new FloatingPointBigScale(1.0734M, -5);
				FloatingPointBigScale _normalizedNumber = _number.Normalize_09();
				FloatingPointBigScale _normalizedNumberMustBe = new FloatingPointBigScale(1.0734M, -5);
				_okTest8 = _normalizedNumberMustBe.SameInFormat(_normalizedNumber);
			}
			{
				FloatingPointBigScale _number = new FloatingPointBigScale(0.0010734M, -5);
				FloatingPointBigScale _normalizedNumber = _number.Normalize_09();
				FloatingPointBigScale _normalizedNumberMustBe = new FloatingPointBigScale(1.0734M, -8);
				_okTest9 = _normalizedNumberMustBe.SameInFormat(_normalizedNumber);
			}
			{
				FloatingPointBigScale _number = new FloatingPointBigScale(-107.34M, -5);
				FloatingPointBigScale _normalizedNumber = _number.Normalize_09();
				FloatingPointBigScale _normalizedNumberMustBe = new FloatingPointBigScale(-1.0734M, -3);
				_okTest10 = _normalizedNumberMustBe.SameInFormat(_normalizedNumber);
			}
			{
				FloatingPointBigScale _number = new FloatingPointBigScale(-1.0734M, -5);
				FloatingPointBigScale _normalizedNumber = _number.Normalize_09();
				FloatingPointBigScale _normalizedNumberMustBe = new FloatingPointBigScale(-1.0734M, -5);
				_okTest11 = _normalizedNumberMustBe.SameInFormat(_normalizedNumber);
			}
			{
				FloatingPointBigScale _number = new FloatingPointBigScale(-0.0010734M, -5);
				FloatingPointBigScale _normalizedNumber = _number.Normalize_09();
				FloatingPointBigScale _normalizedNumberMustBe = new FloatingPointBigScale(-1.0734M, -8);
				_okTest12 = _normalizedNumberMustBe.SameInFormat(_normalizedNumber);
			}
			{
				FloatingPointBigScale _number = new FloatingPointBigScale(0M, 5);
				FloatingPointBigScale _normalizedNumber = _number.Normalize_09();
				FloatingPointBigScale _normalizedNumberMustBe = new FloatingPointBigScale(0M, 5);
				_okTest13 = _normalizedNumberMustBe.SameInFormat(_normalizedNumber);
			}
			{
				FloatingPointBigScale _number = new FloatingPointBigScale(0M, -5);
				FloatingPointBigScale _normalizedNumber = _number.Normalize_09();
				FloatingPointBigScale _normalizedNumberMustBe = new FloatingPointBigScale(0M, -5);
				_okTest14 = _normalizedNumberMustBe.SameInFormat(_normalizedNumber);
			}
			{
				FloatingPointBigScale _number = new FloatingPointBigScale(0M, 0);
				FloatingPointBigScale _normalizedNumber = _number.Normalize_09();
				FloatingPointBigScale _normalizedNumberMustBe = new FloatingPointBigScale(0M, 0);
				_okTest15 = _normalizedNumberMustBe.SameInFormat(_normalizedNumber);
			}
		}
コード例 #2
0
		private static void TestCompareTo()
		{
			bool _okTest1, _okTest2, _okTest3, _okTest4, _okTest5, _okTest6, _okTest7, _okTest8, _okTest9, _okTest10, _okTest11, _okTest12, _okTest13, _okTest14, _okTest15, _okPrueba16;

			{
				FloatingPointBigScale  _number1 = new FloatingPointBigScale(0M, 5);
				FloatingPointBigScale _number2 = new FloatingPointBigScale(0M, 5);
				int   _answerCompareMustBe_1_2 = 0;
				int   _answerCompareMustBe_2_1 = 0;

				int    _answerCompare_1_2 = _number1.CompareTo(_number2);
				int   _answerCompare_2_1 = _number2.CompareTo(_number1);

				_okTest1 = _answerCompare_1_2 == _answerCompareMustBe_1_2;
				_okTest2 = _answerCompareMustBe_2_1 == _answerCompare_2_1;
			}

			{
				FloatingPointBigScale _number1 = new FloatingPointBigScale(5M, 5);
				FloatingPointBigScale _number2 = new FloatingPointBigScale(-5M, 5);
				int _answerCompareMustBe_1_2 = 1;
				int _answerCompareMustBe_2_1 = -1;

				int _answerCompare_1_2 = _number1.CompareTo(_number2);
				int _answerCompare_2_1 = _number2.CompareTo(_number1);

				_okTest3 = _answerCompare_1_2 == _answerCompareMustBe_1_2;
				_okTest4 = _answerCompareMustBe_2_1 == _answerCompare_2_1;
			}

			{
				FloatingPointBigScale _number1 = new FloatingPointBigScale(5M, -55);
				FloatingPointBigScale _number2 = new FloatingPointBigScale(-5M, 5);
				int _answerCompareMustBe_1_2 = 1;
				int _answerCompareMustBe_2_1 = -1;

				int _answerCompare_1_2 = _number1.CompareTo(_number2);
				int _answerCompare_2_1 = _number2.CompareTo(_number1);

				_okTest5 = _answerCompare_1_2 == _answerCompareMustBe_1_2;
				_okTest6 = _answerCompareMustBe_2_1 == _answerCompare_2_1;
			}

			{
				FloatingPointBigScale _number1 = new FloatingPointBigScale(0.001M, 55);
				FloatingPointBigScale _number2 = new FloatingPointBigScale(0.0002M, 55);
				int _answerCompareMustBe_1_2 = 1;
				int _answerCompareMustBe_2_1 = -1;

				int _answerCompare_1_2 = _number1.CompareTo(_number2);
				int _answerCompare_2_1 = _number2.CompareTo(_number1);

				_okTest7 = _answerCompare_1_2 == _answerCompareMustBe_1_2;
				_okTest8 = _answerCompareMustBe_2_1 == _answerCompare_2_1;
			}

			{
				FloatingPointBigScale _number1 = new FloatingPointBigScale(-5M, 2);
				FloatingPointBigScale _number2 = new FloatingPointBigScale(-5M, 3);
				int _answerCompareMustBe_1_2 = 1;
				int _answerCompareMustBe_2_1 = -1;

				int _answerCompare_1_2 = _number1.CompareTo(_number2);
				int _answerCompare_2_1 = _number2.CompareTo(_number1);

				_okTest9 = _answerCompare_1_2 == _answerCompareMustBe_1_2;
				_okTest10 = _answerCompareMustBe_2_1 == _answerCompare_2_1;
			}

			{
				FloatingPointBigScale _number1 = new FloatingPointBigScale(-5M, -2);
				FloatingPointBigScale _number2 = new FloatingPointBigScale(-5M, -3);
				int _answerCompareMustBe_1_2 = -1;
				int _answerCompareMustBe_2_1 = 1;

				int _answerCompare_1_2 = _number1.CompareTo(_number2);
				int _answerCompare_2_1 = _number2.CompareTo(_number1);

				_okTest11 = _answerCompare_1_2 == _answerCompareMustBe_1_2;
				_okTest12 = _answerCompareMustBe_2_1 == _answerCompare_2_1;
			}

			{
				FloatingPointBigScale _number1 = new FloatingPointBigScale(-5M, 2);
				FloatingPointBigScale _number2 = new FloatingPointBigScale(-5M, 3);
				int _answerCompareMustBe_1_2 = 1;
				int _answerCompareMustBe_2_1 = -1;

				int _answerCompare_1_2 = _number1.CompareTo(_number2);
				int _answerCompare_2_1 = _number2.CompareTo(_number1);

				_okTest13 = _answerCompare_1_2 == _answerCompareMustBe_1_2;
				_okTest14 = _answerCompareMustBe_2_1 == _answerCompare_2_1;
			}

			{
				FloatingPointBigScale _number1 = new FloatingPointBigScale(5M, -2);
				FloatingPointBigScale _number2 = new FloatingPointBigScale(5M, -3);
				int _answerCompareMustBe_1_2 = 1;
				int _answerCompareMustBe_2_1 = -1;

				int _answerCompare_1_2 = _number1.CompareTo(_number2);
				int _answerCompare_2_1 = _number2.CompareTo(_number1);

				_okTest15 = _answerCompare_1_2 == _answerCompareMustBe_1_2;
				_okPrueba16 = _answerCompareMustBe_2_1 == _answerCompare_2_1;
			}

		}
コード例 #3
0
		/// <summary>
		/// if the numbers is equal the other one, not just in a manner about the content but also as it is represented
		/// </summary>
		/// <param name="numero"></param>
		/// <returns></returns>
		public bool SameInFormat(FloatingPointBigScale number)
		{
			bool _answer = (number != null) && (number.numericalBase == this.numericalBase && number.exponent == this.exponent);
			return _answer;
		}