What would be the result of the following divisions?
Code:a. 1/0 b. 1/INFINITY c. INFINITY/0 d. 0/INFINITY e. INFINITY/1 f. INFINITY/INFINITY g. 0/0
What would be the result of the following divisions?
Code:a. 1/0 b. 1/INFINITY c. INFINITY/0 d. 0/INFINITY e. INFINITY/1 f. INFINITY/INFINITY g. 0/0
Negative infinity - 42. Obviously.
C99 at least is guaranteed to follow IEEE guidelines.Code:#include <stdio.h> #include <math.h> int main(void) { float a = 1.0f; float b = 0.0f; float c = INFINITY; printf("%f %f %f %f %f %f %f\n", a/b, a/c, c/b, b/c, c/a, c/c, b/b); return 0; }
Are you asking with respect to the rules of some branch of mathematics or a programming language?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
a. undefined
b. nearly zero
c. undefined
d. zero
e. infinity
f. 1
g.undefined (I think)
M.Eng Computer Engineering CandidateB.Sc Computer Science
Robotics and graphics enthusiast.
Trying to remember from calc 2 (it has been awhile and was probably the least useful semester) but isn't the division by inf indeterminate? IIRC you can talk about a variable as it approaches infinity but you can't use infinity as a number.
This would be a critical question to get an answer to, as there is sometimes a significant difference between theoretical math and how a computer performs under those circumstances. Although I'm sure that both normally treat x/0 as "division by zero", where this normally leads to a hardware exception in a computer [so it stops the application] (but this is also usually configurable).
As so often is the case, the question is not clear enough in it's scope to give a complete answer.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
In B I believe you would have to say that limit is zero as infinity is approached. But in D I was under the impression that whether you can treat infinity as a number or not, zero divided by anything had to be zero. And in F, anything divided by itself was always one.Originally Posted by Thantos
I could be completely wrong though. Only one year of precalc under my belt .
M.Eng Computer Engineering CandidateB.Sc Computer Science
Robotics and graphics enthusiast.
Well, for f, consider (x^2)/x. Both go to infinity as x gets large, but the quotient is still infinity. (And of course, you can go the other way to get a quotient of zero, which is why f is undefined.)
I don't think f is undefined but is indeterminate. I gotta dig out the book I think
And really since all but two are talking about infinity I have to assume that really means that as the function approaches some value it goes towards infinity. With the 0 it really depends if you mean:
x / 0
or
x/f(y) as y approaches some number that causes f(y) to approach 0.
I always thought that infinity is not a number, but a process, so an expression like 1/infinity is invalid and meaningless. You can express it as a limit, however, as in "(lim x->inf) 1/x". In that case, it's asking what value does 1/x approach as x approaches infinity. The answer would be 0.
Anything divided by zero is undefined. "(lim x->0+) 1/x", though, is +inf, whereas "(lim x->0-) 1/x", is -inf.
I have only taken one calculus course, though (AP calculus. graduating highschool this year ), so correct me if I'm wrong.