views:

184

answers:

2

I am learning Objective-C using Stephen Kochan's excellent book "Programming in Objective-C 2.0". I am new also to Xcode. So far all my exercises have worked fine, but when I run program 7.6 FractionTest on page 153 I get the console message "Program received signal: "EXC_ARITHMETIC". The status shows that the program succeeded, but I don't see any output. Can anybody suggest what I might be doing wrong?

+3  A: 

Check that if the denominator is zero (i.e. a divide-by-zero error).


EXC_ARITHMETIC (SIGFPE) is signaled when the CPU detects an invalid calculation. Some causes include divide by zero, integer overflow, etc., and integer divide by zero is most likely the reason since you're implementing a Fraction class.

KennyTM
Dear KennyTMOnce again, thanks for your help. I hadn't seen that I had left an important line out of my code, resulting ultimately in a divide by zero error. The program works well now.Kind RegardsDerry
Derry
A: 

EXC_ARITHMETIC is an exception in some sort of floating point operation. I don't have a copy of Programming in Objective-C 2.0, so I can't look up the problem. A code listing might be helpful.

If I had to take a stab in the dark, though, I'd say it might be a division-by-zero error.

mipadi
Dear mipadiOnce again, thanks for your help. I hadn't seen that I had left an important line out of my code, resulting ultimately in a divide by zero error. The program works well now.Kind RegardsDerry
Derry