LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-14-2006, 11:49 PM   #1
newbie_adm
Member
 
Registered: Jun 2006
Posts: 40

Rep: Reputation: 15
Math with 2 decimal places


Hi. I'm doing a script that will calculate for total number of minutes or average min per call in asterisk. Me problem is that, when I do the math, It never resulted with decimal numbers which I really need. Here is an example of what I'm calculating

70/60/5

where 70 is the total usage of call in seconds.

where 60 is equivqlent to 1 min.(i have to divide 70 by 60. answer would be 1.16

where 5 is the total successful calls. I have to divide that total minutes(1.16)to 5 calls
that would 0.233

The script is prompting just 0.
I need the 0.233

How can I do this in my script?

Here is my example script.

TMECNSUMED=`cat master.txt | sed 's/ /\t/g' | grep "ANSWERED" | awk '{print $2}'`
seconcdr=0 #controls for the i
b=0 #Variable counter for row
for i in $TMECNSUMED
do

(( seconcdr = $i + $seconcdr ))
(( b = b + 1 ))
done

(( seconcdr= ($seconcdr/60)/$b))

Pleasehelp me on this thanks

Best Regards,
newbie_adm
 
Old 09-15-2006, 12:14 AM   #2
w3bd3vil
Senior Member
 
Registered: Jun 2006
Location: Hyderabad, India
Distribution: Fedora
Posts: 1,191

Rep: Reputation: 49
if you want variables in points then define them as float.
float $variable
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
math program that I can enter math functions ... Four General 5 04-19-2006 08:02 PM
rounding a large double to 2 decimal places linuxmandrake Programming 2 03-17-2006 03:31 PM
how to print 2 decimal places of a double? nadroj Programming 6 07-12-2005 11:03 AM
Decimal to binary maldini1010 Programming 6 02-01-2005 04:03 PM
limit result of float to two decimal places Strus Programming 3 12-17-2004 08:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration