Re: Procedure for percent of a value
- From: tomk <tom.krehbiel@xxxxxxxxxxxxx>
- Date: Fri, 29 Feb 2008 07:13:31 -0800 (PST)
On Feb 29, 7:51 am, Marcos Martinez Sancho <noem...@xxxxxxxxxx> wrote:
Hello,
I need a small procedure for calculate the percent of a value
e.g.
set srate [expr int(($tps_ok / $number_of_total_tps)*100)]
puts "\nTEST RESULT: $number_of_total_tps tps of which $tps_ok PASSED and
$tps_nok FAILED so $srate % succes rate"
doesnt look optimal and is not working except when srate = 100%. Otherwise,
I get 0%.
Any input is appreciated.
Thanks
Marcos
% set tps_ok 20.0
20.0
% set number_of_total_tps 200
200
% set srate [expr int(($tps_ok / $number_of_total_tps)*100)]
10
% % set tps_ok 20
20
% set srate [expr int(($tps_ok / $number_of_total_tps)*100)]
0
%
I suspect you're passing in integers instead of real values.
Tom K.
.
- References:
- Procedure for percent of a value
- From: Marcos Martinez Sancho
- Procedure for percent of a value
- Prev by Date: Tk8.5: Tk_PhotoSetSize vs Tk_PhotoSetSize_Panic
- Next by Date: Re: serial communication with tcl
- Previous by thread: Procedure for percent of a value
- Next by thread: Re: Procedure for percent of a value
- Index(es):