Hello All!
I just have a quick little question that I have not been
able to solve myself. Within a program being developed in
VS.NET, I have written a private function with the
following code:
Private Function FmaxTest()
Dim varianceHi, varianceLo, Fmax As Double
........
(In this part of the code, the values of varianceHi and
varianceLo are established; depending on the dataset, it
is possible that varianceLo = 0 in some scenarios.)
........
Try
Fmax = varianceHi / varianceLo
Catch ex As NotFiniteNumberException
MsgBox("Division by zero not allowed.")
Exit Function
End Try
........
(This part of the code is for reporting the values of
varianceHi, varianceLo, and Fmax.)
........
End Function
I originally tried the DivideByZeroException, but
discovered that it was for use only with integers. I then
tried NotFiniteNumberException because (as I understand
it) it will throw an exception when there is +infinity, -
infinity, or NaN.
However, in such cases where varianceLo = 0, there are no
exceptions thrown, the algorithm continues as normal, and
the value of Fmax is reported to be Infinity. Any ideas
about what I am doing wrong? Thanks in advance for any
ideas. 5 2105
Haven't got a clue about the problem, but in practical terms why not just
use a...
If varianceLo = 0 Then
....somewhere?
Sorry if that's not esoteric enough.
"Brent Hill" <br****@okstate.edu> wrote in message
news:1c*****************************@phx.gbl... Hello All!
I just have a quick little question that I have not been able to solve myself. Within a program being developed in VS.NET, I have written a private function with the following code:
Private Function FmaxTest() Dim varianceHi, varianceLo, Fmax As Double ....... (In this part of the code, the values of varianceHi and varianceLo are established; depending on the dataset, it is possible that varianceLo = 0 in some scenarios.) ....... Try Fmax = varianceHi / varianceLo Catch ex As NotFiniteNumberException MsgBox("Division by zero not allowed.") Exit Function End Try ....... (This part of the code is for reporting the values of varianceHi, varianceLo, and Fmax.) ....... End Function
I originally tried the DivideByZeroException, but discovered that it was for use only with integers. I then tried NotFiniteNumberException because (as I understand it) it will throw an exception when there is +infinity, - infinity, or NaN.
However, in such cases where varianceLo = 0, there are no exceptions thrown, the algorithm continues as normal, and the value of Fmax is reported to be Infinity. Any ideas about what I am doing wrong? Thanks in advance for any ideas.
Hi,
The / operation will not throw an exception when you divide by zero.
Take a look at double.ispositiveinfinity, double.isnegativeinfinity, and
double.isnan
If Double.IsPositiveInfinity(1.1 / 0.0) Then
MessageBox.Show("Divide by zero")
End If
Ken
--------------------------
"Brent Hill" <br****@okstate.edu> wrote in message
news:1c*****************************@phx.gbl... Hello All!
I just have a quick little question that I have not been able to solve myself. Within a program being developed in VS.NET, I have written a private function with the following code:
Private Function FmaxTest() Dim varianceHi, varianceLo, Fmax As Double ....... (In this part of the code, the values of varianceHi and varianceLo are established; depending on the dataset, it is possible that varianceLo = 0 in some scenarios.) ....... Try Fmax = varianceHi / varianceLo Catch ex As NotFiniteNumberException MsgBox("Division by zero not allowed.") Exit Function End Try ....... (This part of the code is for reporting the values of varianceHi, varianceLo, and Fmax.) ....... End Function
I originally tried the DivideByZeroException, but discovered that it was for use only with integers. I then tried NotFiniteNumberException because (as I understand it) it will throw an exception when there is +infinity, - infinity, or NaN.
However, in such cases where varianceLo = 0, there are no exceptions thrown, the algorithm continues as normal, and the value of Fmax is reported to be Infinity. Any ideas about what I am doing wrong? Thanks in advance for any ideas.
That is what I have been using for this particular type of
exception. However, I was thinking that it would be much
more practical to enclose all my calculations in a single
Try..Catch...Finally statement rather than create an
If...Then statement for each of the *many* calculations to
be performed. I would have to create many If...Then
statements because very few of the calculations being
performed share the same denominator term.
So, esoterica is not my concern, only pragmatics. But
thanks for trying anyway! -----Original Message----- Haven't got a clue about the problem, but in practical
terms why not justuse a...
If varianceLo = 0 Then
....somewhere?
Sorry if that's not esoteric enough.
"Ken Tucker [MVP]" <vb***@bellsouth.net> schrieb Hi,
The / operation will not throw an exception when you divide by zero. Take a look at double.ispositiveinfinity, double.isnegativeinfinity, and double.isnan
If Double.IsPositiveInfinity(1.1 / 0.0) Then
MessageBox.Show("Divide by zero")
End If
Is this also valid?
if (1.1/0.0) = double.positiveinfinity then
It works, so I think it is, but I'm not 100% sure.
--
Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
Hi,
Yes.
Ken
---------------
"Armin Zingler" <az*******@freenet.de> wrote in message
news:40***********************@news.freenet.de... "Ken Tucker [MVP]" <vb***@bellsouth.net> schrieb Hi,
The / operation will not throw an exception when you divide by zero. Take a look at double.ispositiveinfinity, double.isnegativeinfinity, and double.isnan
If Double.IsPositiveInfinity(1.1 / 0.0) Then
MessageBox.Show("Divide by zero")
End If
Is this also valid? if (1.1/0.0) = double.positiveinfinity then
It works, so I think it is, but I'm not 100% sure.
-- Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: eScrewDotCom |
last post by:
eScrew
Welcome to eScrew!
eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew
story if you promise eScrew to consider eScrew story as joke. eScrew
story is very funny. eScrew...
|
by: Brandon J. Van Every |
last post by:
What's better about Ruby than Python? I'm sure there's something. What is
it?
This is not a troll. I'm language shopping and I want people's answers. I
don't know beans about Ruby or have...
|
by: Brandon J. Van Every |
last post by:
I'm realizing I didn't frame my question well.
What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump
up in your chair and scream "Wow! Ruby has *that*? That is SO...
|
by: eScrewDotCom |
last post by:
eScrew
Welcome to eScrew!
eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew
story if you promise eScrew to consider eScrew story as joke. eScrew
story is very funny. eScrew...
|
by: Sarah Tanembaum |
last post by:
Beside its an opensource and supported by community, what's the fundamental
differences between PostgreSQL and those high-price commercial database (and
some are bloated such as Oracle) from...
| |
by: eScrewDotCom |
last post by:
www.eScrew.com
eScrew
Welcome to eScrew!
eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew
story if you promise eScrew to consider eScrew story as joke. eScrew
story is...
|
by: eScrewDotCom |
last post by:
eScrew
Welcome to eScrew!
eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew
story if you promise eScrew to consider eScrew story as joke. eScrew
story is very funny. eScrew...
|
by: Edward Yang |
last post by:
A few days ago I started a thread "I think C# is forcing us to write
more (redundant) code" and got many replies (more than what I had
expected). But after reading all the replies I think my...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |