473,503 Members | 1,858 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A question about NotFiniteNumberException

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.
Nov 20 '05 #1
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.

Nov 20 '05 #2
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.

Nov 20 '05 #3
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.

Nov 20 '05 #4
"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
Nov 20 '05 #5
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

Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2821
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...
220
18803
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...
54
6502
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...
8
2447
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...
125
14539
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...
5
2981
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...
0
2431
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...
7
3123
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...
0
7202
marktang
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,...
0
7280
Oralloy
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,...
0
7330
jinu1996
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...
0
7460
tracyyun
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...
0
4672
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...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
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 ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.