public function stripTrailingZeros() : BigDecimal
    {
        if ($this->scale === 0) {
            return $this;
        }

        $trimmedValue = \rtrim($this->value, '0');

        if ($trimmedValue === '') {
            return BigDecimal::zero();
        }

        $trimmableZeros = \strlen($this->value) - \strlen($trimmedValue);

        if ($trimmableZeros === 0) {
            return $this;
        }

        if ($trimmableZeros > $this->scale) {
            $trimmableZeros = $this->scale;
        }

        $value = \substr($this->value, 0, -$trimmableZeros);
        $scale = $this->scale - $trimmableZeros;

        return new BigDecimal($value, $scale);
    }
public function stripTrailingZeros() : BigDecimal
    {
        if ($this->scale === 0) {
            return $this;
        }

        $trimmedValue = \rtrim($this->value, '0');

        if ($trimmedValue === '') {
            return BigDecimal::zero();
        }

        $trimmableZeros = \strlen($this->value) - \strlen($trimmedValue);

        if ($trimmableZeros === 0) {
            return $this;
        }

        if ($trimmableZeros > $this->scale) {
            $trimmableZeros = $this->scale;
        }

        $value = \substr($this->value, 0, -$trimmableZeros);
        $scale = $this->scale - $trimmableZeros;

        return new BigDecimal($value, $scale);
    }
public function stripTrailingZeros ( ) : BigDecimal { if ( $ this -> scale === 0 ) { return $ this ; } $ trimmedValue = \ rtrim ( $ this -> value , '0' ) ; if ( $ trimmedValue === '' ) { return BigDecimal :: zero ( ) ; } $ trimmableZeros = \ strlen ( $ this -> value ) - \ strlen ( $ trimmedValue ) ; if ( $ trimmableZeros === 0 ) { return $ this ; } if ( $ trimmableZeros > $ this -> scale ) { $ trimmableZeros = $ this -> scale ; } $ value = \ substr ( $ this -> value , 0 , - $ trimmableZeros ) ; $ scale = $ this -> scale - $ trimmableZeros ; return new BigDecimal ( $ value , $ scale ) ; }
Returns a copy of this BigDecimal with any trailing zeros removed from the fractional part.

@return BigDecimal
Returns a copy of this BigDecimal with any trailing zeros removed from the fractional part .