{"id":409,"date":"2022-08-30T15:00:52","date_gmt":"2022-08-30T15:00:52","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/cs-pow-function-refuses-to-work-with-variable-exponent-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:00:52","modified_gmt":"2022-08-30T15:00:52","slug":"cs-pow-function-refuses-to-work-with-variable-exponent-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/cs-pow-function-refuses-to-work-with-variable-exponent-collection-of-common-programming-errors\/","title":{"rendered":"C&#39;s pow function refuses to work with variable exponent-Collection of common programming errors"},"content":{"rendered":"<p>It&#8217;s a very interesting behavior, and a good learning example.<\/p>\n<p>To solve your problem, add<\/p>\n<pre><code>-lm\n<\/code><\/pre>\n<p>to your gcc command line (provided you&#8217;re using gcc). This tells the compiler to link against the math library.<\/p>\n<p>What seems to be going on, is that if you&#8217;re using<\/p>\n<pre><code>pow(2.0, 3);\n<\/code><\/pre>\n<p>the compiler realizes this expression evaluates to a constant, and does mere substitution.<\/p>\n<p>Thus, no library function has to be called.<\/p>\n<p id=\"rop\"><small>Originally posted 2013-11-09 19:03:22. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>It&#8217;s a very interesting behavior, and a good learning example. To solve your problem, add -lm to your gcc command line (provided you&#8217;re using gcc). This tells the compiler to link against the math library. What seems to be going on, is that if you&#8217;re using pow(2.0, 3); the compiler realizes this expression evaluates to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-409","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/409","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=409"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/409\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=409"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}