예제 #1
0
        public void Abs(Integer value, Integer expected)
        {
            using (Immutability.Guard(value))
            {
                var actual = value.Abs();

                Assert.Equal(expected, actual);
            }
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns>a < b: - 1; a == b: 0; a > b: == 1</b></returns>
        public static int Compare(Integer a, Integer b)
        {
            int i = Natural.Compare(a.Abs(), b.Abs());

            if (i == 0 && a.IsZero())
            {
                return(0);
            }
            return((a.Positive ? 1 : -1) * (a.Positive != b.Positive ? 1 : i));
        }
예제 #3
0
 public static Integer Power(Integer b, Natural e) => new Integer()
 {
     natural = Natural.Power(b.Abs(), e), Positive = b.Positive ? true : (e & 1) == 0
 };