Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 09-15-2006, 12:49 AM   #1
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


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

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

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

Pleasehelp me on this thanks

Best Regards,
Old 09-15-2006, 01:14 AM   #2
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 09:02 PM
rounding a large double to 2 decimal places linuxmandrake Programming 2 03-17-2006 04:31 PM
how to print 2 decimal places of a double? nadroj Programming 6 07-12-2005 12:03 PM
Decimal to binary maldini1010 Programming 6 02-01-2005 05:03 PM
limit result of float to two decimal places Strus Programming 3 12-17-2004 09:42 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:10 AM.

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