0

I am trying to validate a form which returns the result (stored in a double) as -1.#IND (which I have been informed is infinity minus one?) How can I trap this error?

-- Background info: The form captures data about a real world object (with 100s of parameters), does a calculation which is handled by a service which returns a result via a 'result' object. The calculation service is doing several calculations which are stored as doubles in the object. There are 6 results returned by the service. The results should fall in the range 0-100. I assume that a divide by zero has occurred somewhere in the calculation which results in the condition mentioned but would like to trap this condition to provide a more specific error message.

Note: I do not have access to the calculation service code.

At the moment I just want to test (pseudo code):

If myRating.value = -1.#IND Then
    ReportError("Divide by zero occurred somewhere in the calc")
End if
JohnnyBizzle
  • 971
  • 3
  • 17
  • 31
  • 2
    How is this "result" being returned to you? What sort of form is this? We're lacking all kinds of information here... – Jon Skeet Mar 28 '14 at 17:34

1 Answers1

0

Depending on how this is actually represented, you should be able to use Double.IsNaN or Double.IsNegativeInfinity to test for not-a-number and negative infinity representations from Visual Basic.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373