{"id":1331,"date":"2022-03-03T06:53:33","date_gmt":"2022-03-03T06:53:33","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=1331"},"modified":"2022-03-03T06:53:33","modified_gmt":"2022-03-03T06:53:33","slug":"round-a-number","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/03\/03\/round-a-number\/","title":{"rendered":"Round a Number"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Round a Number using format<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>public class Decimal {\n\n    public static void main(String&#91;] args) {\n        double num = 1.34567;\n\n        System.out.format(\"%.4f\", num);\n    }\n}<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><samp>1.3457<\/samp><\/code><\/pre>\n\n\n\n<p>In the above program, we&#8217;ve used the format() method to print the given floating-point number&nbsp;<var>num<\/var>&nbsp;to 4 decimal places.&nbsp; The 4 decimal places are given by the format&nbsp;<code>.4f.<\/code><\/p>\n\n\n\n<p>This means, print only up to 4 places after&nbsp;<strong>the dot<\/strong>&nbsp;(decimal places), and&nbsp;<var>f<\/var>&nbsp;means to print the floating-point number.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Round a Number using format Output In the above program, we&#8217;ve used the format() method to print the given floating-point number&nbsp;num&nbsp;to 4 decimal places.&nbsp; The 4 decimal places are given by the format&nbsp;.4f. This means, print only up to 4 places after&nbsp;the dot&nbsp;(decimal places), and&nbsp;f&nbsp;means to print the floating-point number.<\/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\/1331"}],"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=1331"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1331\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=1331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=1331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=1331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}