How do you do math?

How do you do math?

$this->num = $this->num1 + $this->num2 / 60 + $this->num3 / 3600;

I don’t think I understand the question?

Is this a floating point question? I have in the past almost exclusively worked with currency amounts so I tend to gravitate towards the BC Math library.

[ot]How do I do math?

The math I do… I don’t think can be implemented in PHP.[/ot]

Just so you know, the above can be implemented as such:

<?php
class TimeOfDay{
    protected $Hours;
    protected $Minutes;
    protected $Seconds;
    public function __Construct($Hours = 0, $Minutes = 0, $Seconds = 0){
        $this->Hours = $Hours;
        $this->Minutes = $Minutes;
        $this->Seconds = $Seconds;
    }
    public function getSecondsSinceMidnight(){
        return $this->Seconds + $this->Minutes / 60 + $this->Hours / 3600;
    }
}
$Time = new TimeOfDay(19, 26, 52);
echo $Time->getSecondsSinceMidnight();

I’m guessing you’re not getting the answer you expect because of operator precedence http://php.net/manual/en/language.operators.precedence.php Put some brackets in and it should fix it.

Shouldn’t those be * instead of / to get the number of seconds?

Thats the last time I copy/paste from the OP :stuck_out_tongue:

That’s great but please explain your question.