I don't understand, do you study? If you remember.
public static long round (double a) {Long longbits = Double.doubletorawlongbits (a); Long Biasedexp = (Longbits & doubleconsts.exp_bit_mask) >> (doubleconsts.significand_width-1); Long shift = (doubleconsts.significand_width-2 + doubleconsts.exp_bias)-biasedexp; if (Shift & -64) = = 0) {//shift >= 0 && Shift <//A is a finite number such that POW (2 , -64) <= Ulp (a) < 1 long R = ((Longbits & Doubleconsts.signif_bit_mask) | (Doubleconsts.signif_bit_mask + 1)); if (Longbits < 0) {R = R; }//In the comments below per Java expression evaluates to the value//the corresponding Mathemat ical expression://(R) evaluates to A/ulp (a)//(R >> Shift) evaluates to floor (A * 2) (r >> Shift) + 1) evaluates to floor ((A + 1/2) * 2) ((r >> Shift) + 1) >> 1) evaluates to floor (A + a) return ((R >> Shift) + 1) >> 1; } else {//A is either//-a finite number with ABS (a) < exp (2,doubleconsts.significand_width-6 4) </-a finite number with ULP (a) >= 1 and hence A was a mathematical integer//-an I Nfinity or NaN return (long) A; } }
Java-round function Source Code