Convert : if the value is 0 for humansize, return 0.000
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5731 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -105,6 +105,13 @@ class test_convert extends PHPUnit_Framework_TestCase
|
||||
$this->assertSame ($res, "-12.35kB");
|
||||
}
|
||||
|
||||
public function test_humanSize_8 ()
|
||||
{
|
||||
$res = \convert::humanSize (0, 2);
|
||||
$this->assertSame ($res, "0.00B");
|
||||
}
|
||||
|
||||
|
||||
public function test_humanSize_error1 ()
|
||||
{
|
||||
$this->expectException ("Exception",
|
||||
|
||||
@@ -131,12 +131,17 @@ class convert
|
||||
6 => 'E', // exa
|
||||
7 => 'Z', // zetta
|
||||
8 => 'Y');// yotta
|
||||
for ($factor = 8 ; $factor >= -8 ; $factor--)
|
||||
for ($factor = 8 ; $factor > -8 ; $factor--)
|
||||
{
|
||||
if (abs ($value) >= pow ($power, $factor))
|
||||
break;
|
||||
}
|
||||
if ($factor > 0)
|
||||
if ($value == 0)
|
||||
{
|
||||
$display = 0;
|
||||
$factor = 0;
|
||||
}
|
||||
elseif ($factor > 0)
|
||||
$display = $value / pow ($power, $factor);
|
||||
elseif ($factor < 0)
|
||||
$display = $value * pow ($power, -1 * $factor);
|
||||
|
||||
Reference in New Issue
Block a user