| View previous topic :: View next topic |
| Author |
Message |
TALES Halfop

Joined: 09 Nov 2003 Posts: 59 Location: Netherlands
|
Posted: Fri Jan 13, 2006 12:26 pm Post subject: round average |
|
|
im having trouble with the round() what i have is this:
| Code: |
set outputcounter3 [expr (([join $outputmysql " + "] - $min - $max) / ($i - 2)) * 100]
set outputcounter3 [expr round($outputcounter3)]
|
what i have are some numbers in outputmysql like:
25.20 25.9 28.83 24.98 19.94 28.99 29.29 27.94 26.71 28.19 27.06 22.49
so i join "+" them to get them all calc. i do minus the $min and the $max and divide that with 10 i get an output of 29.5877777778 but i want 29.59 to be msg in channel so what i did was * 100 and round the number i get 2959 so i was thinking devide that with 100 i get 29.59 but no i get 29
what am i doing wrong ? and how do i get the right number 29.59 |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Fri Jan 13, 2006 12:38 pm Post subject: |
|
|
you must divide by 100.0
expr won't return float values from integer calculations.
You should read the manual till the bottom: http://www.tcl.tk/man/tcl8.4/TclCmd/expr.htm#M47 _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens... |
|
| Back to top |
|
 |
TALES Halfop

Joined: 09 Nov 2003 Posts: 59 Location: Netherlands
|
Posted: Fri Jan 13, 2006 1:41 pm Post subject: |
|
|
many tnx it worked
greets TALES |
|
| Back to top |
|
 |
|