What is "-1. #IND" in VB.NET

Asked

Viewed 102 times

1

I have a variable that is receiving this value, which is not a STRING, so what is it? And has some way to detect if the variable is equal to that through an IF?

  • 1

    Give a context of where i Sto is occurring, put the code.

  • This is a negative infinity and you can try to condition using the double.Isnan() function to check if it is a number or not (hint).

  • Wrong autocomplete, the correct is undefined negative.

  • The Double.Isnan() worked, thank you very much.

1 answer

1

Negative Undefined "-1. #IND"

The NaN Indefinido, which is a special kind of NaN silent is generated under specific conditions. If you run a invalid arithmetic operation how to add positive infinity and negative infinity, or take the square root of a negative number, then the IEEE standard requires the result to be a NaN silent, but does not seem to specify exactly what NaN silent . Different manufacturers of ponto flutuante They chose different paths. The indefinite term NaN refers to this NaN silent special, whatever the processor ends up choosing it to be.

Some floating point processors generate a NaN silent with the signal bits clear, but the signal bit set. Adjusting the signal bit makes the result negative, then in these processors, you will see the indefinido NaN rendered as an undefined negative Nan. (x86 is one such processor.)

Other processors of ponto flutuante generate a NaN silent with signal bits and signal bit all clear. Clearing the signal bit makes the result positive, so in these processors, you will see the undefined Nan rendered as an undefined positive Nan.

In practice, the difference is not important, because anyway, you will have a NaN indefinido.

Text translated from https://blogs.msdn.microsoft.com/oldnewthing/20130221-00/? p=5183

How to validate - example:

double a = 1, b = 0, c = 0;
double resultado = (a - b) / c;
if (double.IsNaN(resultado)) {
   Console.WriteLine("Não é um número!");
} else {
   Console.WriteLine("Número válido!");
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.