public function trunc($x)
    {
        $sign = $this->sign($x);
        switch ($sign) {
            case -1:
                return ceil($x);
            case 1:
                return floor($x);
            default:
                return $sign;
        }
    }