Esempio n. 1
0
 /**
  * @param string|int|float|\Enimiste\Math\VO\FloatNumber $value
  *
  * @param int                                            $scale
  *
  * @return \Enimiste\Math\VO\FloatNumber
  */
 function as_float_number($value, $scale = 2)
 {
     if ($value instanceof \Enimiste\Math\VO\FloatNumber) {
         return $value->copy($scale);
     } else {
         if ($scale < 0) {
             throw new \RuntimeException('Scale should be >= 0');
         }
         if ($value instanceof \Enimiste\Math\VO\IntegerNumber) {
             $value = $value->__toString();
         }
         return new \Enimiste\Math\VO\FloatNumber($value, $scale);
     }
 }