|
-
Dec 3rd, 2003, 11:40 PM
#1
Thread Starter
Fanatic Member
[resolved] True False - Division by zero
Is there such an equation where n=0 returns value t=0 or otherwise returns a constant, such as t=1? t = n/n works, but 0/0 results in a divsion by zero problem. Is there an equation to get the same result without division by zero?
Last edited by WorkHorse; Dec 4th, 2003 at 02:15 AM.
-
Dec 4th, 2003, 12:07 AM
#2
y=x
x=1; y=1
x=0; y=0
No division by zero needed 
Did you mean to return the same constant every time?
Last edited by jemidiah; Dec 4th, 2003 at 12:12 AM.
The time you enjoy wasting is not wasted time.
Bertrand Russell
<- Remember to rate posts you find helpful.
-
Dec 4th, 2003, 12:35 AM
#3
Thread Starter
Fanatic Member
Return the same value for t no matter what n is, except when n is zero.
t = the equation of n
VB Code:
n = 1 t = 1
n = 0.00000000000001 t = 1
n = 958.54 t = 1
n = 65487 t = 1
n = -1 t = 1
n = -0.6598 t = 1
n = -9999 t = 1
n = -456.78 t = 1
n = 0 t = 0
(I can't get the spacing to match up, but you see the point.)
Last edited by WorkHorse; Dec 4th, 2003 at 12:45 AM.
-
Dec 4th, 2003, 12:53 AM
#4
Frenzied Member
i dont know y u dont want to use an if then statement but:
-
Dec 4th, 2003, 12:57 AM
#5
Thread Starter
Fanatic Member
Originally posted by dis1411
i dont know y u dont want to use an if then statement but:
This begs the question. What is the mathematical equation to determine n <> 0?
-
Dec 4th, 2003, 01:26 AM
#6
Frenzied Member
what exactly r u trying to do?
youre not going to get it much simpler than what i gave
-
Dec 4th, 2003, 01:41 AM
#7
Thread Starter
Fanatic Member
I guess I am asking for the mathematical equation for NOT. How can you manually calculate that something is NOT something? Specifically, that something is NOT zero? How can I take any n and trun it to 1, unless n = 0? Is there a formula for n <> 0. Or is there NOT?
-
Dec 4th, 2003, 02:04 AM
#8
transcendental analytic
WorkHorse: n <> 0 is a mathematical inequality, not an equality
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Dec 4th, 2003, 02:08 AM
#9
transcendental analytic
Re: True False - Division by zero
Originally posted by WorkHorse
Is there such an equation where n=0 returns value t=0 or otherwise returns a constant, such as t=1? t = n/n works, but 0/0 results in a divsion by zero problem. Is there an equation to get the same result without division by zero?
as for this: t=|sgn n|
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Dec 4th, 2003, 02:10 AM
#10
Thread Starter
Fanatic Member
Originally posted by kedaman
WorkHorse: n <> 0 is a mathematical inequality, not an equality
Does that mean t = n <> 0 cannot be expessed more simplicity? The equation operator NOT is what it is by definition and cannot be difined by another equation?
-
Dec 4th, 2003, 02:14 AM
#11
Thread Starter
Fanatic Member
Re: Re: True False - Division by zero
Originally posted by kedaman
as for this: t=|sgn n|
Brilliant. That's the ticket. Thank you.
-
Dec 4th, 2003, 02:16 AM
#12
transcendental analytic
well, not is a boolean operator, and you should distinguish between boolean and aritmetic algebra
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Dec 4th, 2003, 03:19 AM
#13
Frenzied Member
ooops i was thinking in VB
-
Dec 10th, 2003, 12:09 AM
#14
Fanatic Member
factorial
Here's a little trick i used in something recently:
Code:
n*(n-1)!
----------
n!
Note that when n =0, fraction = 0*(-1)!/0! = 0
and for all else the fraciton = 1;
I think there may be a slight problem though, as factorials aren't defined for all numbers (n must be a non-negative integer or .5 less than a non-negative integer), but i believe there is a general factorial function, which would provide what is needed.
sql_lall 
-
Dec 14th, 2003, 08:23 PM
#15
For possibly simplifying n <> 0, the CPU's arithmetic and logic unit handles that by comparing the two numbers logically instead of using some arithmetic operations, so you'd have to find a function that happens to do what sql_lall's does to use the arithmetic method that you're after. BTW, that's pretty clever!
The time you enjoy wasting is not wasted time.
Bertrand Russell
<- Remember to rate posts you find helpful.
-
Dec 16th, 2003, 06:05 AM
#16
Hyperactive Member
There is a small problem
n*(n-1)!
----------
n!
will fail if n or (n-1) is a negative number as factorial of negative number is not defined....
-1! is not defined...
so we can use abs for that....
just a little modification :
|n|*|(n-1)|!
----------
|n|!
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
|