{"id":1335,"date":"2022-03-03T06:58:41","date_gmt":"2022-03-03T06:58:41","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=1335"},"modified":"2022-03-03T06:58:41","modified_gmt":"2022-03-03T06:58:41","slug":"convert-int-to-double","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/03\/03\/convert-int-to-double\/","title":{"rendered":"Convert int to double"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Convert int to double using Typecasting<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>class Main {\n  public static void main(String&#91;] args) {\n\n    \/\/ create int variables\n    int a =33;\n    int b = 29;\n\n    \/\/ convert int into double\n    \/\/ using typecasting\n    double c = a;\n    double d = b;\n\n    System.out.println(c);    \/\/ 33.0\n    System.out.println(d);    \/\/ 29.0\n  }\n}<\/code><\/pre>\n\n\n\n<p>In the above example, we have&nbsp;<code>int<\/code>&nbsp;type variables&nbsp;<var>a<\/var>&nbsp;and&nbsp;<var>b<\/var>. Notice the line,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>double c = a;<\/code><\/pre>\n\n\n\n<p>Here, the&nbsp;<code>int<\/code>&nbsp;type variable is automatically converted into&nbsp;<code>double<\/code>. It is because&nbsp;<code>double<\/code>&nbsp;is a higher data type (data type with larger size) and&nbsp;<code>int<\/code>&nbsp;is a lower data type (data type with smaller size).<\/p>\n\n\n\n<p>Hence, there will be no loss in data while converting from&nbsp;<code>int<\/code>&nbsp;to&nbsp;<code>double<\/code>. This is called&nbsp;<strong>widening typecasting<\/strong>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Convert int to double using Typecasting In the above example, we have&nbsp;int&nbsp;type variables&nbsp;a&nbsp;and&nbsp;b. Notice the line, Here, the&nbsp;int&nbsp;type variable is automatically converted into&nbsp;double. It is because&nbsp;double&nbsp;is a higher data type (data type with larger size) and&nbsp;int&nbsp;is a lower data type (data type with smaller size). Hence, there will be no loss in data while converting [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[287],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1335"}],"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=1335"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1335\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=1335"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=1335"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=1335"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}