1 51 package org.apache.fop.fo.expr; 52 53 import org.apache.fop.fo.Property; 54 import org.apache.fop.fo.NumberProperty; 55 56 class RoundFunction extends FunctionBase { 57 public int nbArgs() { 58 return 1; 59 } 60 61 public Property eval(Property[] args, 62 PropertyInfo pInfo) throws PropertyException { 63 Number dbl = args[0].getNumber(); 64 if (dbl == null) 65 throw new PropertyException("Non number operand to round function"); 66 double n = dbl.doubleValue(); 67 double r = Math.floor(n + 0.5); 68 if (r == 0.0 && n < 0.0) 69 r = -r; return new NumberProperty(r); 71 } 72 73 } 74 | Popular Tags |