comparison mgtool.php @ 249:abcd21b01829

Use floating point formatting for certain DVA values.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 29 Oct 2018 20:32:59 +0200
parents 438277861f51
children 3af3b3f50cb0
comparison
equal deleted inserted replaced
248:2656b64c4c04 249:abcd21b01829
138 case MG_BOOL: return intval($val); 138 case MG_BOOL: return intval($val);
139 case MG_DVA: 139 case MG_DVA:
140 if (sscanf($val, "%d/%d", $v1, $v2) == 2 && $v2 != 0 && $v1 != 0) 140 if (sscanf($val, "%d/%d", $v1, $v2) == 2 && $v2 != 0 && $v1 != 0)
141 { 141 {
142 if ($v1 < $v2) 142 if ($v1 < $v2)
143 return "1/".($v2 / $v1); 143 return sprintf("1/%1.1f", $v2 / $v1);
144 else 144 else
145 return sprintf("%1.1f", $v1 / $v2); 145 return sprintf("%1.1f", $v1 / $v2);
146 } 146 }
147 else 147 else
148 return $val; 148 return $val;