ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   indeterminate 0/0 (https://www.excelbanter.com/excel-discussion-misc-queries/102160-indeterminate-0-0-a.html)

integreat

indeterminate 0/0
 

Is there a way to force VBA to do a division by zero without giving the
"divide by zero" error. I need a way to overrride this error but need
0/0 to equal 1


--
integreat
------------------------------------------------------------------------
integreat's Profile: http://www.excelforum.com/member.php...o&userid=34282
View this thread: http://www.excelforum.com/showthread...hreadid=566460


Dave Peterson

indeterminate 0/0
 
You can check the numerator and denominator to see if either/both are equal to
0.

Bob Phillips

indeterminate 0/0
 
Perhaps

Function DivideBy(denom, div)

If denom = 0 And div = 0 Then
DivideBy = 1
Else
DivideBy = denom / div
End If

End Function

MsgBox DivideBy(0,0)

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"integreat" wrote
in message ...

Is there a way to force VBA to do a division by zero without giving the
"divide by zero" error. I need a way to overrride this error but need
0/0 to equal 1


--
integreat
------------------------------------------------------------------------
integreat's Profile:

http://www.excelforum.com/member.php...o&userid=34282
View this thread: http://www.excelforum.com/showthread...hreadid=566460




Bernard Liengme

indeterminate 0/0
 
Just in case you really do want Visual Basic:

Function mydivider(a, b)
If b < 0 Then
temp = a / b
ElseIf a = 0 Then
temp = 1
End If
mydivider = temp
End Function


best wishes
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"integreat" wrote
in message ...

Is there a way to force VBA to do a division by zero without giving the
"divide by zero" error. I need a way to overrride this error but need
0/0 to equal 1


--
integreat
------------------------------------------------------------------------
integreat's Profile:
http://www.excelforum.com/member.php...o&userid=34282
View this thread: http://www.excelforum.com/showthread...hreadid=566460




Dana DeLouis

indeterminate 0/0
 
"divide by zero" error. I need a way to override this error but need
0/0 to equal 1


Hi. Just for discussion, 0/0 is an "Overflow" error.

Sub Demo()
Dim Ans
On Error Resume Next

'// 6 Overflow
Ans = 0 / 0
Debug.Print Err.Number; Err.Description

'// 11 Division by zero
Ans = 2 / 0
Debug.Print Err.Number; Err.Description

'// Maybe...
If Err.Number = 6 Then Ans = 1
Err.Clear
On Error GoTo 0
End Sub

(But you are correct, certain math programs treat 0/0 as Indeterminate vs
Excel's Overflow)
--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


"integreat" wrote
in message ...

Is there a way to force VBA to do a division by zero without giving the
"divide by zero" error. I need a way to overrride this error but need
0/0 to equal 1


--
integreat
------------------------------------------------------------------------
integreat's Profile:
http://www.excelforum.com/member.php...o&userid=34282
View this thread: http://www.excelforum.com/showthread...hreadid=566460




Dave Peterson

indeterminate 0/0
 
And that indeterminate makes sense, too.

numerator/demoninator = Quotient

which means that
numerator = Quotient * denominator

If the denominator is 0 and the numerator is non-zero, there are no non-zero
numerators that could make:
numerator = quotient * 0
correct.

If both the denominator and numerator = 0, then there are way too many correct
answers that make this:

0 = quotient * 0
(0 * any number = 0, so all numbers are correct)





Dana DeLouis wrote:

"divide by zero" error. I need a way to override this error but need
0/0 to equal 1


Hi. Just for discussion, 0/0 is an "Overflow" error.

Sub Demo()
Dim Ans
On Error Resume Next

'// 6 Overflow
Ans = 0 / 0
Debug.Print Err.Number; Err.Description

'// 11 Division by zero
Ans = 2 / 0
Debug.Print Err.Number; Err.Description

'// Maybe...
If Err.Number = 6 Then Ans = 1
Err.Clear
On Error GoTo 0
End Sub

(But you are correct, certain math programs treat 0/0 as Indeterminate vs
Excel's Overflow)
--
HTH. :)
Dana DeLouis
Windows XP, Office 2003

"integreat" wrote
in message ...

Is there a way to force VBA to do a division by zero without giving the
"divide by zero" error. I need a way to overrride this error but need
0/0 to equal 1


--
integreat
------------------------------------------------------------------------
integreat's Profile:
http://www.excelforum.com/member.php...o&userid=34282
View this thread: http://www.excelforum.com/showthread...hreadid=566460


--

Dave Peterson

Dana DeLouis

indeterminate 0/0
 
Hi. Other arguments for "indeterminate" are with limits. If you take the
limit of x/x as x approaches 0, then the answer is 1.(2x/x is 2..etc)
The correct answer to what you want with 0/0 depends on what you are doing.
Hence...indeterminate. Interesting.
--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


"Dave Peterson" wrote in message
...
And that indeterminate makes sense, too.

numerator/demoninator = Quotient

which means that
numerator = Quotient * denominator

If the denominator is 0 and the numerator is non-zero, there are no
non-zero
numerators that could make:
numerator = quotient * 0
correct.

If both the denominator and numerator = 0, then there are way too many
correct
answers that make this:

0 = quotient * 0
(0 * any number = 0, so all numbers are correct)





Dana DeLouis wrote:

"divide by zero" error. I need a way to override this error but need
0/0 to equal 1


Hi. Just for discussion, 0/0 is an "Overflow" error.

Sub Demo()
Dim Ans
On Error Resume Next

'// 6 Overflow
Ans = 0 / 0
Debug.Print Err.Number; Err.Description

'// 11 Division by zero
Ans = 2 / 0
Debug.Print Err.Number; Err.Description

'// Maybe...
If Err.Number = 6 Then Ans = 1
Err.Clear
On Error GoTo 0
End Sub

(But you are correct, certain math programs treat 0/0 as Indeterminate vs
Excel's Overflow)
--
HTH. :)
Dana DeLouis
Windows XP, Office 2003

"integreat"
wrote
in message ...

Is there a way to force VBA to do a division by zero without giving the
"divide by zero" error. I need a way to overrride this error but need
0/0 to equal 1


--
integreat
------------------------------------------------------------------------
integreat's Profile:
http://www.excelforum.com/member.php...o&userid=34282
View this thread:
http://www.excelforum.com/showthread...hreadid=566460


--

Dave Peterson





All times are GMT +1. The time now is 05:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com