Division by zero in weight.php

PHP Warning: Division by zero in ******\PHP\htdocs\online\system\library\weight.php on line 38

right code:

public function convert($value, $from, $to) {
if ($from == $to) {
return $value;
}

if (isset($this->weights[$from])) {
$from = $this->weights[$from]['value'];
} else {
$from = 0;
}

if (isset($this->weights[$to])) {
$to = $this->weights[$to]['value'];
} else {
$to = 0;
}

if($from == 0){
return $value;
return @($value * ($to / $from));
}

//return $value * ($to / $from); – this should be commented