Location: PHPKode > projects > Rainbow Trading > rgbtrade/includes/rgbDimension.php
<?php
  class rgbDimension {
    var $value;

  function rgbDimension() {
    $this->value = 0;
  }
  function setValue($value) {
    $this->value = $value;
  }
  function setFractedValue($rounded,$fracted) {
    // unsplit 1 and 1/8 into 1.125
    // if (!is_numeric($rounded) || !is_numeric($fracted)) {
    if (!is_numeric($rounded) || !preg_match("/[0-9]\/[[0-9]/",$fracted)) {
      $message = "Incorrect fracted values $rounded and $fracted";
      pc_debug($message,__FILE__,__LINE__);
      return false;
    } else {
      $sum = $rounded +  $fracted / 8 ; 
      $this->setValue($sum);
      $message = "correct fracted values $rounded and $fracted setting to . $sum"; 
      pc_debug($message,__FILE__,__LINE__);
    }
  }

  function getValue() {
    return (float) $this->value;
  }

  function getRoundedValue() {
    if ($this->getValue() >0 ) {
       $message = 'rounding ' . $this->getValue() . 'to' . floor($this->getValue()) ;
       // pc_debug($message,__FILE__,__LINE__);
       return (int) floor($this->getValue());
    } else {
       $message = 'rounding ' . $this->getValue() . 'to' . ceil($this->getValue()) ;
       // pc_debug($message,__FILE__,__LINE__);
       return (int) ceil($this->getValue());
    }
  }


  function getFraction() {
    // returns something like 0.125
    $fraction = (float) ($this->getValue() - $this->getRoundedValue()); 
    return abs($fraction);
  }

  function get8th() {
    // return something like "5/8"
    // if ($this->getFraction() <> 0) {
      return (string)  $this->getFraction() * 8 . "/8";
    // } else {
     //  return "0/8";
    // }
  }

}
?>
Return current item: Rainbow Trading