Class DecimalMath


  • public class DecimalMath
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      DecimalMath()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static long[] add​(long[] u, long[] v)
      Knuth TAoCP 4.3.1 Algorithm A Addition of nonnegative n-place integers u and v, returning the sum w.
      static boolean allzero​(long[] data, int len)  
      static int cmp​(long a, long b)  
      static int compare​(long[] a, long[] b, int shift)  
      static int digitCount​(long w)  
      static DecimalMath.DivideResult divide​(long[] uc, long[] vc)
      Knuth TAoCP 4.3.1 Algorithm D Division of nonnegative integer u by v, returning the quotient q and remainder r.
      static DecimalMath.DivideResult divideword​(long[] u, long v)
      Knuth TAoCP 4.3.1 Exercise 16 Division of a nonnegative integer u by a single word v, returning the quotient q and remainder r.
      static long[] divpow10​(long[] d, long n, int exp)  
      static long[] divword​(long[] d, long n, long div)  
      static long[] multiply​(long[] u, long[] v)
      Knuth TAoCP 4.3.1 Algorithm M Multiplication of nonnegative integers u and v, returning the product w.
      static void multiplyword​(long[] w, long[] u, long n, long v)
      Multiplication of a nonnegative integer u by a single word v, returning the product w.
      static DecimalMath.MathCtx parseMathContext​(RoundingModeType rounding, MathContext context)  
      static long[] push​(long[] arr, long elem)  
      static long[] subtract​(long[] u, long[] v)
      Knuth TAoCP 4.3.1 Algorithm S Subtraction of nonnegative n-place integers u >= v, returning the sum w.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DecimalMath

        public DecimalMath()
    • Method Detail

      • add

        public static long[] add​(long[] u,
                                 long[] v)
        Knuth TAoCP 4.3.1 Algorithm A Addition of nonnegative n-place integers u and v, returning the sum w. Numbers must already be aligned and length u >= length v.
      • subtract

        public static long[] subtract​(long[] u,
                                      long[] v)
        Knuth TAoCP 4.3.1 Algorithm S Subtraction of nonnegative n-place integers u >= v, returning the sum w. Numbers must already be aligned and length u >= length v.
      • multiply

        public static long[] multiply​(long[] u,
                                      long[] v)
        Knuth TAoCP 4.3.1 Algorithm M Multiplication of nonnegative integers u and v, returning the product w.
      • multiplyword

        public static void multiplyword​(long[] w,
                                        long[] u,
                                        long n,
                                        long v)
        Multiplication of a nonnegative integer u by a single word v, returning the product w. See TAoCP 4.3.1 exercise 13.
      • divide

        public static DecimalMath.DivideResult divide​(long[] uc,
                                                      long[] vc)
        Knuth TAoCP 4.3.1 Algorithm D Division of nonnegative integer u by v, returning the quotient q and remainder r.
      • digitCount

        public static int digitCount​(long w)
      • divideword

        public static DecimalMath.DivideResult divideword​(long[] u,
                                                          long v)
        Knuth TAoCP 4.3.1 Exercise 16 Division of a nonnegative integer u by a single word v, returning the quotient q and remainder r.
      • compare

        public static int compare​(long[] a,
                                  long[] b,
                                  int shift)
      • allzero

        public static boolean allzero​(long[] data,
                                      int len)
      • cmp

        public static int cmp​(long a,
                              long b)
      • push

        public static long[] push​(long[] arr,
                                  long elem)
      • divpow10

        public static long[] divpow10​(long[] d,
                                      long n,
                                      int exp)
      • divword

        public static long[] divword​(long[] d,
                                     long n,
                                     long div)