{"id":1868,"date":"2020-05-26T14:25:35","date_gmt":"2020-05-26T14:25:35","guid":{"rendered":"https:\/\/yazilimperver.com\/?p=1868"},"modified":"2020-05-26T14:25:35","modified_gmt":"2020-05-26T14:25:35","slug":"haftalik-c-28-onaltili-kayan-noktali-sayi-sabitleri-floating-point-literals","status":"publish","type":"post","link":"https:\/\/yazilimperver.com\/index.php\/2020\/05\/26\/haftalik-c-28-onaltili-kayan-noktali-sayi-sabitleri-floating-point-literals\/","title":{"rendered":"[:tr]Haftal\u0131k C++ 28 \u2013 Onalt\u0131l\u0131 kayan noktal\u0131 say\u0131 sabitleri (Floating point literals)[:]"},"content":{"rendered":"<p>[:tr]Evet arkada\u015flar, modern C++ ile gelen kabiliyetlere g\u00f6z atmaya devam ediyoruz. Bu yaz\u0131mda da, k\u0131saca C++ 17 ile gelen bir kabiliyetten bahsedece\u011fim:<em>Onalt\u0131l\u0131 kayan noktal\u0131 (floating) say\u0131 sabitleri<\/em>.<\/p>\n<p>Normalde tam say\u0131lar i\u00e7in C ve C++ da onalt\u0131l\u0131 d\u00fczende sabitler tan\u0131mlanabilse de, kayan noktal\u0131 say\u0131lar i\u00e7in b\u00f6yle bir kabliyet yoktu, c++ 17 ile birlikte art\u0131k var.<br \/>\nHemen bu say\u0131lar\u0131n nas\u0131l tan\u0131mlanabilece\u011fine bakal\u0131m:<\/p>\n<p><span style=\"color: #ff0000;\"><strong>&#8220;0x&lt;Onalt\u0131l\u0131k Tamsay\u0131 K\u0131sm\u0131&gt;.&lt;Onalt\u0131l\u0131k kesirli k\u0131sm\u0131&gt;p&lt;\u0130kinin ka\u00e7\u0131nc\u0131 kuvveti oldu\u011fu&gt;&#8221;<\/strong><\/span><\/p>\n<p>\u015feklinde tan\u0131mlanabilmektedir. Exponent p k\u0131sm\u0131 bu sabitler i\u00e7in her zaman eklenmelidir. Noktan \u00f6nce 16 ve katlar\u0131 sonras\u0131nda ise 1\/16 ve katlar\u0131 olarak say\u0131 hesaplan\u0131p, en son p ye g\u00f6re, b\u00fct\u00fcn say\u0131 \u00e7arp\u0131larak sabit elde edilmekte. Hemen \u00f6rnekler \u00fczerinden gidelim:<\/p>\n<pre class=\"lang:c++ decode:true\">#include &lt;iostream&gt;\r\n\r\nint main()\r\n{\r\n      std::cout &lt;&lt; \"\\\"0x0p0\\\"    : \" &lt;&lt; 0x0p0     &lt;&lt; \"\\n\"; \/\/ ( 0.0 + 0.0\/16 )*(2 uzeri 0)\r\n      std::cout &lt;&lt; \"\\\"0x0.p0\\\"   : \" &lt;&lt; 0x0.p0    &lt;&lt; \"\\n\"; \/\/ ( 0.0 + 0.0\/16 )*(2 uzeri 0)\r\n      std::cout &lt;&lt; \"\\\"0x.1p0\\\"   : \" &lt;&lt; 0x.1p0    &lt;&lt; \"\\n\"; \/\/ ( 0.0 + 1.0\/16 )*(2 uzeri 0)\r\n      std::cout &lt;&lt; \"\\\"0x0.1p0\\\"  : \" &lt;&lt; 0x0.1p0   &lt;&lt; \"\\n\"; \/\/ ( 0.0 + 1.0\/16 )*(2 uzeri 0)\r\n      std::cout &lt;&lt; \"\\\"0x1.1p0\\\"  : \" &lt;&lt; 0x1.1p0   &lt;&lt; \"\\n\"; \/\/ ( 1.0 + 1.0\/16 )*(2 uzeri 0)\r\n      std::cout &lt;&lt; \"\\\"0x1.2p0\\\"  : \" &lt;&lt; 0x1.2p0   &lt;&lt; \"\\n\"; \/\/ ( 1.0 + 2.0\/16 )*(2 uzeri 0)\r\n      std::cout &lt;&lt; \"\\\"0x2.2p0\\\"  : \" &lt;&lt; 0x2.2p0   &lt;&lt; \"\\n\"; \/\/ ( 2.0 + 2.0\/16 )*(2 uzeri 0)\r\n      std::cout &lt;&lt; \"\\\"0x2.2p1\\\"  : \" &lt;&lt; 0x2.2p1   &lt;&lt; \"\\n\"; \/\/ ( 2.0 + 2.0\/16 )*(2 uzeri 1)\r\n      std::cout &lt;&lt; \"\\\"0x2.2p2\\\"  : \" &lt;&lt; 0x2.2p2   &lt;&lt; \"\\n\"; \/\/ ( 2.0 + 2.0\/16 )*(2 uzeri 2)\r\n      std::cout &lt;&lt; \"\\\"0x10.01p0\\\": \" &lt;&lt; 0x10.01p0 &lt;&lt; \"\\n\"; \/\/ (16.0 + 1.0\/(16 uzeri 2))*(2 uzeri 0)\r\n      std::cout &lt;&lt; \"\\\"0x10.01p1\\\": \" &lt;&lt; 0x10.01p1 &lt;&lt; \"\\n\"; \/\/ (16.0 + 1.0\/(16 uzeri 2))*(2 uzeri 1)\r\n      std::cout &lt;&lt; \"\\\"0x10.01p-1\\\": \" &lt;&lt; 0x10.01p-1 &lt;&lt; \"\\n\"; \/\/ (16.0 + 1.0\/(16 uzeri 2))*(2 uzeri -1). Buna dikkat carptigimiz sayi 0.5 oluyor. yani 1\/2\r\n      std::cout &lt;&lt; \"\\\"0x0.001p0\\\": \" &lt;&lt; 0x0.001p0 &lt;&lt; \"\\n\"; \/\/ (16.0 + 1.0\/(16 uzeri 3))*(2 uzeri 0)\r\n      \r\n      return 0;\r\n}<\/pre>\n<p>Yukar\u0131daki \u00f6rnek kodun \u00e7\u0131kt\u0131s\u0131 da a\u015fa\u011f\u0131daki gibi olacakt\u0131r:<\/p>\n<pre class=\"lang:ps decode:true\">\"0x0p0\"    : 0\r\n\"0x0.p0\"   : 0\r\n\"0x.1p0\"   : 0.0625\r\n\"0x0.1p0\"  : 0.0625\r\n\"0x1.1p0\"  : 1.0625\r\n\"0x1.2p0\"  : 1.125\r\n\"0x2.2p0\"  : 2.125\r\n\"0x2.2p1\"  : 4.25\r\n\"0x2.2p2\"  : 8.5\r\n\"0x10.01p0\": 16.0039\r\n\"0x10.01p1\": 32.0078\r\n\"0x10.01p-1\": 8.00195\r\n\"0x0.001p0\": 0.000244141<\/pre>\n<h2><strong><span style=\"color: #0000ff;\">Kaynaklar<\/span><\/strong><\/h2>\n<ul>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/C%2B%2B17\"><span style=\"color: #339966;\"><strong>https:\/\/en.wikipedia.org\/wiki\/C%2B%2B17<\/strong><\/span><\/a><\/li>\n<li><a href=\"http:\/\/en.cppreference.com\/w\/cpp\/language\/floating_literal\"><span style=\"color: #339966;\"><strong>http:\/\/en.cppreference.com\/w\/cpp\/language\/floating_literal<\/strong><\/span><\/a><\/li>\n<\/ul>\n<p>[:]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[:tr]Evet arkada\u015flar, modern C++ ile gelen kabiliyetlere g\u00f6z atmaya devam ediyoruz. Bu yaz\u0131mda da, k\u0131saca C++ 17 ile gelen bir kabiliyetten bahsedece\u011fim:Onalt\u0131l\u0131 kayan noktal\u0131 (floating) say\u0131 sabitleri. Normalde tam say\u0131lar i\u00e7in C ve C++ da onalt\u0131l\u0131 d\u00fczende sabitler tan\u0131mlanabilse de, kayan noktal\u0131 say\u0131lar i\u00e7in b\u00f6yle bir kabliyet yoktu, c++ 17 ile birlikte art\u0131k var. Hemen&#8230; <a class=\"more-link\" href=\"https:\/\/yazilimperver.com\/index.php\/2020\/05\/26\/haftalik-c-28-onaltili-kayan-noktali-sayi-sabitleri-floating-point-literals\/\">Continue reading <span class=\"meta-nav\">&#8594;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":174,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","_seopress_robots_follow":"","_seopress_robots_imageindex":"","_seopress_robots_snippet":"","_seopress_robots_primary_cat":"10","_seopress_robots_breadcrumbs":"","_seopress_robots_freeze_modified_date":"","_seopress_robots_custom_modified_date":"","_seopress_robots_canonical":"","_seopress_social_fb_title":"","_seopress_social_fb_desc":"","_seopress_social_fb_img":"","_seopress_social_fb_img_attachment_id":0,"_seopress_social_fb_img_width":0,"_seopress_social_fb_img_height":0,"_seopress_social_twitter_title":"","_seopress_social_twitter_desc":"","_seopress_social_twitter_img":"","_seopress_social_twitter_img_attachment_id":0,"_seopress_social_twitter_img_width":0,"_seopress_social_twitter_img_height":0,"_seopress_redirections_value":"","_seopress_redirections_enabled":"","_seopress_redirections_enabled_regex":"","_seopress_redirections_logged_status":"","_seopress_redirections_param":"","_seopress_redirections_type":0,"_seopress_analysis_target_kw":"","dsgo_overlay_header":false,"dsgo_overlay_header_text_color":"","dsgo_overlay_skip_top_bar":false,"_designsetgo_exclude_llms":false,"footnotes":""},"categories":[10,41],"tags":[234,739,738,741,740,42,236],"class_list":["post-1868","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c","category-modern-c","tag-c-17","tag-floating-point","tag-floating-point-literals","tag-hexadecimal-float","tag-literal","tag-modern-c","tag-weekly-c"],"_links":{"self":[{"href":"https:\/\/yazilimperver.com\/index.php\/wp-json\/wp\/v2\/posts\/1868","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yazilimperver.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yazilimperver.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yazilimperver.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/yazilimperver.com\/index.php\/wp-json\/wp\/v2\/comments?post=1868"}],"version-history":[{"count":0,"href":"https:\/\/yazilimperver.com\/index.php\/wp-json\/wp\/v2\/posts\/1868\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/yazilimperver.com\/index.php\/wp-json\/wp\/v2\/media\/174"}],"wp:attachment":[{"href":"https:\/\/yazilimperver.com\/index.php\/wp-json\/wp\/v2\/media?parent=1868"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yazilimperver.com\/index.php\/wp-json\/wp\/v2\/categories?post=1868"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yazilimperver.com\/index.php\/wp-json\/wp\/v2\/tags?post=1868"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}