|
-
Sep 9th, 2000, 09:16 PM
#1
Thread Starter
New Member
Ok thanks for all the help so far, got my txtboxes and calculations all working just like they should....except...one calculation is giving a 'divide by zero' error.
Whats the best way to deal with this? Should I just limit the values available for this txtbox so that it can't happen? Or is there another way to make the program either ignore this or return a 'please enter another value' msgbox....or something else????
Thanks,
Scott
Trying to teach myself visual basic
-
Sep 9th, 2000, 09:20 PM
#2
Addicted Member
a division by zero is IMPOSIBLE so vb give you an error..
place that....
Sub ...............
On error goto error1
'calculation operation here
exit sub
error1:
msgbox "Sorry, an error occur in the proccess .." _
& vbcrlf & "Impossible opération ?"
end sub
-
Sep 9th, 2000, 09:45 PM
#3
Member
I'm still not too sure why processor manufacturers can't figure this one out...If you divide by zero obviously the answer is going to be zero.
0 * anything = 0
anything * 0 = 0
0 / anything = 0
anything / 0 = 0
We learned this in math class in first grade (if not kindergarten). Why is such a simple principle ignored when it comes to technology?
And another thing that really p*sses me off is the fact that the operating systems over the years haven't trapped this annoying error. All you have to do is trap the error and change the value to zero! It's really that damn simple!
Yeah, it's probably not the result that your function or application wants but it is the correct formula.
To contrast this why is there no multiply by zero error? It uses the same function...
Just another of the 'acceptable bugs' in processor development.
Glacius Cool
Concept Designer
VB5sp4,VC++6sp3
-
Sep 9th, 2000, 10:46 PM
#4
Thread Starter
New Member
Ok, so how do I make a simple error trap that will tell the program to set anything divided by 0 to = 0?
thanks,
Scott
Trying to teach myself visual basic
-
Sep 10th, 2000, 10:13 AM
#5
Member
Sub...
on error goto Errorhandler
'your code goes here
exit sub
Errorhandler:
If Err.Number=11 then
Result=0
resume Next
Else
Msgbox Err.Description
End If
End Sub
-
Sep 10th, 2000, 10:21 AM
#6
Hyperactive Member
Originally posted by Glacius Cool
I'm still not too sure why processor manufacturers can't figure this one out...If you divide by zero obviously the answer is going to be zero.
Actually you are wrong. You cannot divide by 0! The answer is undefined, not zero!
(I not sure which school you went to.)
You can multiply by 0, but not divide.
-
Sep 10th, 2000, 10:43 AM
#7
PowerPoster
If you divide anything by zero you get infinity.
It's rather hard to display infinity, so VB just vomits.
If this is going to turn into an argument about zeros and infinity then lets mosey on over to the Chit Chat forum and redefine the universe.
Gentile or Jew,
O you who turn the wheel and look to windward,
Consider Phlebas, who was once handsome and tall as you...
-
Sep 10th, 2000, 10:46 AM
#8
You CAN'T divide by zero.
Look at it this way.
1 / 0.1 = 10
1 / 0.01 = 100
1 / 0.001 = 1000
1 / 0.0000000001 = 10000000000
If you keep calculating you'll get an infinite number if you divide by zero, you define it like so:
-
Lim(a / x) = Infinity
x->0
-
-
Sep 10th, 2000, 12:05 PM
#9
Originally posted by Glacius Cool
I'm still not too sure why processor manufacturers can't figure this one out...If you divide by zero obviously the answer is going to be zero.
0 * anything = 0
anything * 0 = 0
0 / anything = 0
anything / 0 = 0
We learned this in math class in first grade (if not kindergarten). Why is such a simple principle ignored when it comes to technology?
I'm with you as far as
0 / anything = 0
because
0 * anything = 0
but if
anything / 0 = 0
then
0 * 0 = anything
and that is incorrect isn't it...???
5 / 0 = 0
would give that
0 * 0 = 5
-
Sep 10th, 2000, 04:08 PM
#10
Hyperactive Member
Originally posted by Arbiter
If you divide anything by zero you get infinity.
It's rather hard to display infinity, so VB just vomits.
If this is going to turn into an argument about zeros and infinity then lets mosey on over to the Chit Chat forum and redefine the universe.
I think we can avoid the chit chat; it is not infinity. It is undefined. I should know , I majored in math - long before computers or calculators and when we still had to
use sliderules. Most of the posters on this board grew up
using calculators.
See this link http://ubmail.ubalt.edu/~harsham/zer...TM#rsimpalgcom
[Edited by dsy5 on 09-10-2000 at 05:13 PM]
-
Sep 10th, 2000, 04:25 PM
#11
_______
<?>
why not just check the value of the divisor before you do the division and if it is zero then exit the sub (with an explanation if you want)
Msgbox "Sorry, division by 0 is not permissible"
End of story.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 10th, 2000, 04:34 PM
#12
Hyperactive Member
Well everyone to divide anything by zero is imposible. The reason for this is because if for say you had 8 pieces of pie and you had to dived it evenly between zero people. Well as you can see you can't give any pizza out there for you can not divide it evenly out. So the answer to anything/0 = undefined like some other people have stated already.
-
Sep 18th, 2000, 04:28 PM
#13
I'm disappointed to learn that 1/0 does not equal infinity (or should that be MAY not).
at the tender age of about 12 I determined that infinity = a chocolate cake (on much the same principle as bulldogs post) as my dear friend Arbiter can attest.
Now my illusions are shattered...
(perhaps this is more suited for Chit-Chat)
-
Sep 19th, 2000, 03:15 AM
#14
PowerPoster
Behemoth - thou hairy man!
I'm upset that you're claiming sole credit for the "infinity is a chocolate cake" theorem.
Perhaps we should regale these people with other such theories (the multiverse is a toastrack...)
I don't want to say lets go on over to chit chat again though.
I think whether anything divided by zero equals infinity depends on what method you use to divide things. If you use the good old fashioned method of; keep subtracting the divisible number from the target number until you hit a number where subtracting further takes you past zero then you have the number of iterations and a remainder.
If zero is the divisible number, you will perform this loop an infinite number of times...
PS Both Behemoth and I have studied maths to a fair degree (though with no *formal* qualifications) and also remember when calculators weren't allowed in exams. This younger generation can even take in their maths text books to help them!! Can't remember quite as far back as the slide rule though...
Gentile or Jew,
O you who turn the wheel and look to windward,
Consider Phlebas, who was once handsome and tall as you...
-
Sep 19th, 2000, 03:51 AM
#15
Conquistador
windows calculator returns:
Error: Positive Infinity
-
Sep 19th, 2000, 07:48 AM
#16
Hyperactive Member
My Windows calculator reports 1/0 as "cannot divide by 0".
-
Sep 19th, 2000, 11:41 AM
#17
I vaguely remeber something in GCSE maths (oh no, im giving my age away!) that implies that if a calculation cannot be done, it is its own solution.
Algebraic law:
1/a = 1/a
Therefore:
1/0 = 1/0.
no messing about. i think perhaps this is stretching rules a bit, but isnt that the whole point of logic?
-
Sep 19th, 2000, 11:53 AM
#18
New Member
Calculus proves that dividing by zero is infinity
10/10=1
10/1=10
10/.1=100
10/.01=1000
....
10/.0000001=100000000
As the value of the divisor gets smaller, the result gets bigger. In calculus, you say "x/y=infinity as y approaches 0".
-
Sep 19th, 2000, 01:48 PM
#19
Hyperactive Member
Re: Calculus proves that dividing by zero is infinity
Originally posted by arneljd
As the value of the divisor gets smaller, the result gets bigger. In calculus, you say "x/y=infinity as y approaches 0".
And the key word here is "approaches" - it does not say 0!
-
Sep 19th, 2000, 02:54 PM
#20
And for the ones that still aren't convinced, read it over at this site:
http://www.drmath.com/dr.math/faq/faq.divideby0.html
-
Sep 19th, 2000, 03:47 PM
#21
Lively Member
Must have my two pennerth
I don't mean to nitpick, but I must have a say in this argument...
As the value of the divisor gets smaller, the result gets bigger. In calculus, you say "x/y=infinity as y approaches 0".
I'm sure that you don't say x/y=infinity you say x/y -> infinity (x/y tends to or approaches infinity).
-
Sep 20th, 2000, 12:58 PM
#22
Actually... The appropriate definition of the 'division by zero' issue is:
_________________
Lim(a / x) = Infinity
x -> 0
Where 'a' represents a finite number.
_________________
By the way, did this thread answer your question?
[Edited by Sc0rp on 09-20-2000 at 02:04 PM]
-
Sep 20th, 2000, 04:59 PM
#23
Sorry Sc0rp, I didn't mean to cause offence.
See, I reasoned that because you used the term "math" (an Americanism), you were American, and would have understood the irony of a Brit telling you how to speak English, (maths), however, I got it (and you) all wrong...
please accept my apologies.
BTW, what is your native language?
-
Sep 20th, 2000, 05:05 PM
#24
good lord Sc0rp, that wolfram site looks deep.
You must understand, I dropped out of A-level maths because my teacher wasn't prepared to listen to my theories about imaginary numbers before we studied them (dont you hate it when teachers do that. you think you discover some incredible idea that would make life so much better, and they're not prepared to go through the theory with you and explain why it would or wouldn't work - mind you, Arbiter, McEwen was always a good one to try to blind with science)
anyway, i digress. this site looks like just what i WANTED to study, and not what i was EXPECTED to study,
cheers
-
Sep 20th, 2000, 05:55 PM
#25
Addicted Member
Division by 0
Print the procedure out, and walk through the data by hand. If that doesn't work then a neat trick to find out where the error is occuring, is to saturate the procedure(s) with message boxes (simply to find out where your error is occuring). Post your variable and the current value in the message box. You should place a message box after each equation line. This is not pretty but it will let you know where your error is occuring. If you discover that the error is a logical one then add 1, and that will eliminate the error. But you need to know where the error is occuring, so use the message boxes. You won't find that one in any class or book. That's what me and the boys call Computer Dope.
The Computer Dope Man
Doc Scheinder
212 will lead you to the truth
-
Sep 20th, 2000, 09:25 PM
#26
Conquistador
that mathworld site is pretty complicated
-
Sep 21st, 2000, 05:11 AM
#27
Behemoth:
- No offence taken.
 - I had a few teachers that wouldn't listen to anyone.
Fortunately I am very patient... - My native language is Hebrew.
-
Sep 21st, 2000, 07:09 AM
#28
OK, you speak Hebrew and have just accepted an apology from someone calling themselves Behemoth...the world just gets weirder...
-
Sep 21st, 2000, 07:21 AM
#29
See my signature.
-
Sep 21st, 2000, 08:11 AM
#30
Frenzied Member
Good night, you guys.
I am 14, and last year I was bored during Geometry so I proved that division by zero leads to infinty. I used all the logic above and got myself smacked into independent study for it. By a teacher who has four degrees in math and has tought for decades.
ITS INFINITY, OK?!?!?!
-
Sep 21st, 2000, 11:38 AM
#31
The simple answer is, division by zero = the cause of scottvb's problem. regardless of whether the final solution is infinity or not, this argument has the potential to be infinitely long. surely, because infinity is an imagined concept, it can be both infinity and NOT infinity at the same time?
-
Sep 21st, 2000, 11:58 AM
#32
Poor scottvb, all he wanted to know is how to solve his problem. 
scottvb: You can't divide by zero so either check if the divisor is zero and let the user know that division by zero is impossible, or set a default result value to be set when zero is detected.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|