{"id":3572,"date":"2022-05-19T05:27:47","date_gmt":"2022-05-19T05:27:47","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=3572"},"modified":"2022-05-19T05:27:47","modified_gmt":"2022-05-19T05:27:47","slug":"dart-number","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/05\/19\/dart-number\/","title":{"rendered":"Dart Number"},"content":{"rendered":"\n<p>The Number is the data type that is used to hold the numeric value. In Dart, It can be two types &#8211;<\/p>\n\n\n\n<ul><li>Integer<\/li><li>Double<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/static.javatpoint.com\/tutorial\/dart\/images\/dart-number.png\" alt=\"Dart Number\"\/><\/figure>\n\n\n\n<p><strong>Dart integer &#8211;<\/strong>\u00a0Integer numbers are the whole numbers means that can be written without a fractional component. For example &#8211; 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\u00a0<strong>int<\/strong>\u00a0keyword is used to declare integer value in\u00a0Dart.<\/p>\n\n\n\n<p><a href=\"https:\/\/www.javatpoint.com\/dart-number#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-number#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-number#\"><\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int id = 501;   <\/code><\/pre>\n\n\n\n<p><strong>Dart Double &#8211;<\/strong>\u00a0The Double number are the numbers that can be written with floating-point numbers or number with larger decimal points. The\u00a0<strong>double<\/strong>\u00a0keyword is used to declare Double value in Dart.<\/p>\n\n\n\n<p><a href=\"https:\/\/www.javatpoint.com\/dart-number#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-number#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-number#\"><\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>double root = 1.41234;  \nor  \ndouble rupees  = 100000;  <\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Rules for the integer value<\/h3>\n\n\n\n<ul><li>An integer value must be a digit.<\/li><li>The decimal points should not include in an integer number.<\/li><li>Unsigned numbers are always a positive number. Numbers can be either negative or positive.<\/li><li>The size of the integer value depends upon the platform, but integer value should no longer than 64 bit.<\/li><\/ul>\n\n\n\n<p>Let&#8217;s have a look at following example &#8211;<\/p>\n\n\n\n<p>Example &#8211;<\/p>\n\n\n\n<p><a href=\"https:\/\/www.javatpoint.com\/dart-number#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-number#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-number#\"><\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void main(){    \n int r = 5;  \n double pi = 3.14;  \n double res = 4*pi*r*r;    \n print(\"The area of sphere = ${(res)}\");  \n}  <\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>The area of sphere 314 \n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Dart parse() function<\/h3>\n\n\n\n<p>The parse() function converts the numeric string to the number. Consider the following example &#8211;<\/p>\n\n\n\n<p>Example &#8211;<\/p>\n\n\n\n<p><a href=\"https:\/\/www.javatpoint.com\/dart-number#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-number#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-number#\"><\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void main(){  \nvar a = num.parse(\"20.56\");  \nvar b = num.parse(\"15.63\");  \n  \nvar c = a+b;   \nprint(\"The sum is = ${c}\");  \n}  <\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>The sum is = 36.19\n<\/code><\/pre>\n\n\n\n<p><strong>Explanation &#8211;<\/strong><\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Number Properties<\/h2>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><th>Properties<\/th><th>Description<\/th><\/tr><tr><td>hashcode<\/td><td>It returns the hash code of the given number.<\/td><\/tr><tr><td>isFinite<\/td><td>If the given number is finite, then it returns true.<\/td><\/tr><tr><td>isInfinite<\/td><td>If the number infinite it returns true.<\/td><\/tr><tr><td>isNan<\/td><td>If the number is non-negative then it returns true.<\/td><\/tr><tr><td>isNegative<\/td><td>If the number is negative then it returns true.<\/td><\/tr><tr><td>sign<\/td><td>It returns -1, 0, or 1 depending upon the sign of the given number.<\/td><\/tr><tr><td>isEven<\/td><td>If the given number is an even then it returns true.<\/td><\/tr><tr><td>isOdd<\/td><td>If the given number is odd then it returns true.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Number Methods<\/h2>\n\n\n\n<p>The commonly used methods of number are given below.<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><th>Method<\/th><th>Description<\/th><\/tr><tr><td>abs()<\/td><td>It gives the absolute value of the given number.<\/td><\/tr><tr><td>ceil()<\/td><td>It gives the ceiling value of the given number.<\/td><\/tr><tr><td>floor()<\/td><td>It gives the floor value of the given number.<\/td><\/tr><tr><td>compareTo()<\/td><td>It compares the value with other number.<\/td><\/tr><tr><td>remainder()<\/td><td>It gives the truncated remainder after dividing the two numbers.<\/td><\/tr><tr><td>round()<\/td><td>It returns the round of the number.<\/td><\/tr><tr><td>toDouble()<\/td><td>It gives the double equivalent representation of the number.<\/td><\/tr><tr><td>toInt()<\/td><td>Returns the integer equivalent representation of the number.<\/td><\/tr><tr><td>toString()<\/td><td>Returns the String equivalent representation of the number<\/td><\/tr><tr><td>truncate()<\/td><td>Returns the integer after discarding fraction digits.<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>The Number is the data type that is used to hold the numeric value. In Dart, It can be two types &#8211; Integer Double Dart integer &#8211;\u00a0Integer numbers are the whole numbers means that can be written without a fractional component. For example &#8211; 20, 30, -3215, 0, etc. An integer number can be signed [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[917],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/3572"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=3572"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/3572\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=3572"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=3572"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=3572"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}