Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does double.NAN exist but num.NAN and int.NAN don't, in Google's Dart programming language?

Tags:

dart

Why does double.NAN exist but num.NAN and int.NAN don't, in Google's Dart programming language?

like image 590
Trevor Boyle Avatar asked Feb 16 '14 12:02

Trevor Boyle


People also ask

What is NUM data type in Dart?

In Dart, all numbers are part of the common Object type hierarchy, and there are two concrete, user-visible numeric types: int , representing integer values, and double , representing fractional values. Depending on the platform, those numeric types have different, hidden implementations.

How do you declare an int in darts?

Numbers in Dart You declare instances of them using the keywords var, int, num or double. Use var if the variable can be dynamic and hold any type of variable. That's more or less as it is in JavaScript. Use int or double to explicitly declare the type of the variables.

What is a double in Dart?

In the Dart programming language, double is a data type that stores decimal numbers (fractional numbers). For each double variable, eight bytes are allocated in the memory. If you try to assign any integer value to the double variable then, by default, it will be cast to the double data type.

How do you compare double NaN?

Use the IsNaN method to determine whether a value is not a number. The Equality operator considers two NaN values to be unequal to one another. In general, Double operators cannot be used to compare Double. NaN with other Double values, although comparison methods (such as Equals and CompareTo) can.


1 Answers

NaN is a specific double value that is specified in the IEEE standard for floating-point values (IEEE 754).

NaN has special properties (like NaN != NaN), and those properties are implemented by the CPU.

Integers do not have any explicit NaN value.

like image 72
Florian Loitsch Avatar answered Oct 12 '22 02:10

Florian Loitsch