private double roundMGRS(double value){
  double ivalue=Math.floor(value);
  long ival;
  double fraction=value - ivalue;
  ival=(long)(ivalue);
  if ((fraction > 0.5) || ((fraction == 0.5) && (ival % 2 == 1)))   ival++;
  return (double)ival;
}

private double roundMGRS ( double value ) { double ivalue = Math . floor ( value ) ; long ival ; double fraction = value - ivalue ; ival = ( long ) ( ivalue ) ; if ( ( fraction > 0.5 ) || ( ( fraction == 0.5 ) && ( ival % 2 == 1 ) ) ) ival ++ ; return ( double ) ival ; }
the function round_mgrs rounds the input value to the nearest integer , using the standard engineering rule . the rounded integer value is then returned .
