This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

round average

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
TALES
Halfop
Posts: 59
Joined: Sun Nov 09, 2003 8:45 am
Location: Netherlands
Contact:

round average

Post by TALES »

im having trouble with the round() what i have is this:

Code: Select all

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
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

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...
User avatar
TALES
Halfop
Posts: 59
Joined: Sun Nov 09, 2003 8:45 am
Location: Netherlands
Contact:

Post by TALES »

many tnx it worked

greets TALES
Post Reply