divided by 0 problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting divided by 0 problem
# 1  
Old 07-15-2009
divided by 0 problem

Hi!

i have a new shell script that will compute for a value...

Code:
 
a = b/(b+c)
c = d/(d+e)
print b" "a" "d" "c

but there will be an instance that either b+c or d+e will be "0".... if b+c or d+e is "0" it will print "#NA#...

pls help me... thanks!
# 2  
Old 07-15-2009
Quote:
Originally Posted by kingpeejay
Code:
 
a = b/(b+c)
c = d/(d+e)
print b" "a" "d" "c


This is your code or this is what you want? Does not look like a valid code?
Where is your code? Please share so that we can try helping you.
# 3  
Old 07-15-2009
it's a part of an awk... i used awk to get the corresponding values for the variables a, b, c, d & e..
# 4  
Old 07-15-2009
Where is your script, what did you try? For the moment show on your post only the requirements.
# 5  
Old 07-15-2009
which shell ? Looks more about awk.
You must test always divide by 0 in every tools. What is value of a if b+c is 0 ?
# 6  
Old 07-15-2009
if the dividend yields a value of "0", then the answer should be "#NA#"

---------- Post updated at 04:35 PM ---------- Previous update was at 04:32 PM ----------

Code:
if((b+c) = "0")
{print b" ""#NA#"" "d" "c}
if((d+e) = "0")
{print b" "a" "d" ""#NA"}

but it yields an error of "you can't divide by zero"
# 7  
Old 07-15-2009
if your dividends is 0, don't do the math just replace it with #NA#
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

sed Or Grep Problem OR Terminal Problem?

I don't know if you guys get this problem sometimes at Terminal but I had been having this problem since yesterday :( Maybe I overdid the Terminal. Even the codes that used to work doesn't work anymore. Here is what 's happening: * I wanted to remove lines containing digits so I used this... (25 Replies)
Discussion started by: Nexeu
25 Replies

2. IP Networking

Problem with forwarding emails (SPF problem)

Hi, This is rather a question from a "user" than from a sys admin, but I think this forum is apropriate for the question. I have an adress with automatic email forwarding and for some senders (two hietherto), emails are bouncing. This has really created a lot of problems those two time so I... (0 Replies)
Discussion started by: carwe
0 Replies

3. Shell Programming and Scripting

sum divided by count

Dear friends, I'm stuck with the task below, I would be thankful for all your replies. INPUT : Date Price Volume 20110601 73052811.61 2845833 20110602 61489062.96 9909230 20110603 72790724.65 1108927 20110606 48299507.20 7435881 20110607 ... (5 Replies)
Discussion started by: hernand
5 Replies

4. UNIX for Dummies Questions & Answers

DHCP problem and eth1 problem

At work I am trying to get this one Linux machine (let's call it ctesgm07) to behave like another Linux machine that we have (let's call it test007). test007 returns the following version info: cat /etc/debian_version: lenny/sid uname -a: Linux test007 2.6.27-7-generic #1 SMP Tue Nov 4... (0 Replies)
Discussion started by: sllinux
0 Replies

5. Red Hat

Mail Problem. Maybe, it is a DNS Problem!

Hi, i've a redhat linux 9 upadated by redhat from 7 version to 9 version. A couple of days ago i was a problem with my mail, in other words i'm not able to get any email nor to send any email. I've a proxy configuration and i tried to set iptables in order to verify the port. The 110,255 and 995... (1 Reply)
Discussion started by: pintalgi
1 Replies

6. AIX

user login problem & Files listing problem.

1) when user login to the server the session got colosed. How will resolve? 2) While firing the command ls -l we are not able to see the any files in the director. but over all view the file system using the command df -g it is showing 91% used. what will be the problem? Thanks in advance. (1 Reply)
Discussion started by: pernasivam
1 Replies

7. Shell Programming and Scripting

ssh script problem problem

Hi Please help me with the following problem with my script. The following block of code is not repeating in the while loop and exiting after searching for first message. input_file ========== host001-01 host001-02 2008-07-23 13:02:04,651 ConnectionFactory - Setting session state... (2 Replies)
Discussion started by: pcjandyala
2 Replies

8. Shell Programming and Scripting

LS with du divided by ls wc-l sub directory average

Hi. I am trying to write a script that will create a list of directories with their total disk usage (including subdirectories) divided by the number of sub directories. so i run an ls like this ls -d */images/*/, and that would give me my list. Then i want to get the du of every directory... (0 Replies)
Discussion started by: Movomito
0 Replies

9. Shell Programming and Scripting

how to write divided function

hi iam facing problem for divided (%) arthemtic function in for condition. tell me reply and all the arthemtic function in one scripting . (2 Replies)
Discussion started by: naveeng.81
2 Replies

10. Shell Programming and Scripting

problem with dd command or maybe AFS problem

Hi, folks. Sorry for bothering, but maybe someone could help me please. The problem is the following: there is some script that copies files from local file system to AFS. The copying is performed with dd command. The script copies data into some AFS volumes. The problem appeared with one... (0 Replies)
Discussion started by: Anta
0 Replies
Login or Register to Ask a Question