Here you can find the source of normalForm(int[] a)
private static int[] normalForm(int[] a)
//package com.java2s; //License from project: LGPL import java.util.Arrays; public class Main { private static int[] normalForm(int[] a) { int d = computeDegree(a); // if a is the zero polynomial if (d == -1) { // return new zero polynomial return new int[1]; }/* w ww . j a v a2 s .c om*/ // if a already is in normal form if (a.length == d + 1) { // return a clone of a return Arrays.copyOf(a, a.length); } // else, reduce a int[] result = new int[d + 1]; System.arraycopy(a, 0, result, 0, d + 1); return result; } @SuppressWarnings("empty-statement") private static int computeDegree(int[] a) { int degree; for (degree = a.length - 1; degree >= 0 && a[degree] == 0; degree--) { //empty } return degree; } }