<?php

class utilMath{
	
	public static function fnround($num, $d=0){
  		$num = sprintf("%.4f",$num);
  		$d = pow(10, $d);
  		
  		if($num == 0){
		    $sgn = 0;
  		}else if($num > 0){
		    $sgn = 1;
  		}else{
		    $sgn = -1;
  		}
  		
  		$v1 = intval((string)($num*$d + $sgn*.5));
  		return ($v1/$d);
	}
		
}