Re: Procedure for percent of a value
- From: suchenwi <richard.suchenwirth-bauersachs@xxxxxxxxxxx>
- Date: Fri, 29 Feb 2008 08:13:10 -0800 (PST)
On 29 Feb., 16:35, Neil Madden <n...@xxxxxxxxxxxxx> wrote:
proc percent {num total} {
expr {double($num)/double($total) * 100}
}
Also, you might have cases where the total is 0. I usually use
proc % {num den} {
if {$den == 0} {return --.---%}
format %.3f%% [expr {$num * 100. / $den}]
}
which returns a string with trailing %, filled with minuses when den
was 0.
.
- References:
- Procedure for percent of a value
- From: Marcos Martinez Sancho
- Re: Procedure for percent of a value
- From: Neil Madden
- Procedure for percent of a value
- Prev by Date: Re: Procedure for percent of a value
- Next by Date: Re: Tk8.5: Tk_PhotoSetSize vs Tk_PhotoSetSize_Panic
- Previous by thread: Re: Procedure for percent of a value
- Next by thread: Re: Procedure for percent of a value
- Index(es):
Relevant Pages
|