Re: decimal numbers
| From: | Tom | Date: | Wed, 10 Jan 2001 16:24:28 +0000 |
| Subject: | Re: decimal numbers | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-4903@lists.php.net to get a copy of this message | ||
$Percent=sprintf("%0.2f",$Percent);
afan wrote:
> Hi all,
> short and simple question:
>
> >From total of 123 elements 79 are ok. What percent?
>
> $Total = 123;
> $ok = 78;
> $Percent = (100 / 123) * 78; // 63.41463414...
>
> But I need just two decimal: 63.41
> I'm doing it this way:
>
> $Percent = $Percent * 10; // 6341.463414...
> settype($Percent, "integer"); // 6341
> $Percent = $Percent / 10; // 63.41
>
> I thing there is much better solution!
>
> Thanks for help
>
> Afan