egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

round average

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
TALES
Halfop


Joined: 09 Nov 2003
Posts: 59
Location: Netherlands

PostPosted: Fri Jan 13, 2006 12:26 pm    Post subject: round average Reply with quote

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
View user's profile Send private message Visit poster's website
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Fri Jan 13, 2006 12:38 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
TALES
Halfop


Joined: 09 Nov 2003
Posts: 59
Location: Netherlands

PostPosted: Fri Jan 13, 2006 1:41 pm    Post subject: Reply with quote

many tnx it worked

greets TALES
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber