public function to($unit, $precision = null)
    {
        $fromUnit = UnitResolver::resolve($this->from);
        $toUnit = UnitResolver::resolve($unit);
        $this->setBase($unit);
        $base = $this->getBase() == 2 ? 1024 : 1000;
        //some funky stuff with negative exponents and pow
        if ($toUnit > $fromUnit)
            return $this->div($this->start, pow($base, $toUnit - $fromUnit), $precision);
        return $this->mul($this->start, pow($base, $fromUnit - $toUnit), $precision);
    }
public function to($unit, $precision = null)
    {
        $fromUnit = UnitResolver::resolve($this->from);
        $toUnit = UnitResolver::resolve($unit);
        $this->setBase($unit);
        $base = $this->getBase() == 2 ? 1024 : 1000;
        //some funky stuff with negative exponents and pow
        if ($toUnit > $fromUnit)
            return $this->div($this->start, pow($base, $toUnit - $fromUnit), $precision);
        return $this->mul($this->start, pow($base, $fromUnit - $toUnit), $precision);
    }
public function to ( $ unit , $ precision = null ) { $ fromUnit = UnitResolver :: resolve ( $ this -> from ) ; $ toUnit = UnitResolver :: resolve ( $ unit ) ; $ this -> setBase ( $ unit ) ; $ base = $ this -> getBase ( ) == 2 ? 1024 : 1000 ; //some funky stuff with negative exponents and pow if ( $ toUnit > $ fromUnit ) return $ this -> div ( $ this -> start , pow ( $ base , $ toUnit - $ fromUnit ) , $ precision ) ; return $ this -> mul ( $ this -> start , pow ( $ base , $ fromUnit - $ toUnit ) , $ precision ) ; }
Convert the start value to the given unit.
Accepts an optional precision for how many significant digits to
retain

@param $unit
@param int|null $precision
@return float
Convert the start value to the given unit . Accepts an optional precision for how many significant digits to retain