dlarchikov / php-amqplib

Automatically exported from code.google.com/p/php-amqplib
GNU Lesser General Public License v2.1
0 stars 0 forks source link

Bug in AMQPDecimal::asBCvalue #19

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

There's a bug in the AMQPDecimal::asBCvalue() as per the following:

class AMQPDecimal
{
    public function __construct($n, $e)
    {
        if($e < 0)
            throw new Exception("Decimal exponent value must be unsigned!");
        $this->n = $n;
        $this->e = $e;
    }

    public function asBCvalue()
    {
        // Should be return bcdiv($this->n, bcpow(10,$this->e));
        return bcdiv($n, bcpow(10,$e));
    }
}

Thanks,
--Robin

Original issue reported on code.google.com by harvey.r...@gmail.com on 14 Nov 2010 at 4:28

GoogleCodeExporter commented 8 years ago
In fact, looking at this again, you could probably do with using a string in 
asBCvalue() as well, strictly speaking the bcpow function needs string inputs:

return bcdiv((string) $this->n, bcpow('10', (string) $this->e));

Original comment by harvey.r...@gmail.com on 14 Nov 2010 at 4:33