Javatpoint Logo
Javatpoint Logo

Dart Number

The Number is the data type that is used to hold the numeric value. In Dart, It can be two types -

  • Integer
  • Double
Dart Number

Dart integer - Integer numbers are the whole numbers means that can be written without a fractional component. For example - 20, 30, -3215, 0, etc. An integer number can be signed or unsigned. The representation of the integer value is in between -263 to 263 non-decimal numbers. The int keyword is used to declare integer value in Dart.

Dart Double - The Double number are the numbers that can be written with floating-point numbers or number with larger decimal points. The double keyword is used to declare Double value in Dart.

Rules for the integer value

  • An integer value must be a digit.
  • The decimal points should not include in an integer number.
  • Unsigned numbers are always a positive number. Numbers can be either negative or positive.
  • The size of the integer value depends upon the platform, but integer value should no longer than 64 bit.

Let's have a look at following example -

Example -

Output:

The area of sphere 314 

Dart parse() function

The parse() function converts the numeric string to the number. Consider the following example -

Example -

Output:

The sum is = 36.19

Explanation -

In the above example, we converted the numeric strings into the numbers by using parse() method then stored in the variables. After the successful conversion, we performed add operation and printed the output to the screen.

Number Properties

Properties Description
hashcode It returns the hash code of the given number.
isFinite If the given number is finite, then it returns true.
isInfinite If the number infinite it returns true.
isNan If the number is non-negative then it returns true.
isNegative If the number is negative then it returns true.
sign It returns -1, 0, or 1 depending upon the sign of the given number.
isEven If the given number is an even then it returns true.
isOdd If the given number is odd then it returns true.

Number Methods

The commonly used methods of number are given below.

Method Description
abs() It gives the absolute value of the given number.
ceil() It gives the ceiling value of the given number.
floor() It gives the floor value of the given number.
compareTo() It compares the value with other number.
remainder() It gives the truncated remainder after dividing the two numbers.
round() It returns the round of the number.
toDouble() It gives the double equivalent representation of the number.
toInt() Returns the integer equivalent representation of the number.
toString() Returns the String equivalent representation of the number
truncate() Returns the integer after discarding fraction digits.

Next TopicDart String





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA