{"id":6414,"date":"2013-09-11T00:00:13","date_gmt":"2013-09-11T00:00:13","guid":{"rendered":"http:\/\/craftydba.com\/?p=6414"},"modified":"2016-04-21T20:45:35","modified_gmt":"2016-04-21T20:45:35","slug":"math-functions-log10-vs-power","status":"publish","type":"post","link":"https:\/\/craftydba.com\/?p=6414","title":{"rendered":"Math Functions &#8211; LOG10() vs POWER()"},"content":{"rendered":"<p>I am going to gain ground on completing my short articles on non-trigonometric Transaction SQL <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/ms177516.aspx\">math functions<\/a>.  Most, if not all, of these functions have been in the product before the release of SQL Server 2005.  <\/p>\n<p>I am very proud of my daughter making the advance math class in sixth grade.  I am dedicating these blogs to her hard class work and love of the subject.<\/p>\n<p>Today, I will be exploring the <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/ms175121.aspx\">LOG10()<\/a> and <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/ms174276.aspx\">POWER()<\/a> functions.   <\/p>\n<p>The <a href=\"http:\/\/en.wikipedia.org\/wiki\/Common_logarithm\">common logarithm<\/a> of number x is the power y to which 10 would have to be raised to equal x.  Before the early 1970&#8217;s, handheld electronic calculators were not yet in widespread use.  Many math books of that time period had common logarithm tables for reference as appendices.  These tables were used in calculating estimates for math on large numbers.  <\/p>\n<p>In short, LOG10 is a function that takes large numbers and makes them smaller.   <\/p>\n<p><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/09\/Math-Log10-Graph.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/09\/Math-Log10-Graph.png\" alt=\"Math-Log10-Graph\" width=\"400\" height=\"249\" class=\"aligncenter size-full wp-image-6425\" srcset=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/09\/Math-Log10-Graph.png 400w, https:\/\/craftydba.com\/wp-content\/uploads\/2013\/09\/Math-Log10-Graph-300x186.png 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<p>The common logarithm of 120 is 2.079181 in which the characteristic is 2 and the mantissa is 0.079181.  The inverse function of LOG10(x) is POWER(10, x).  Thus, POWER(10, 2.079181) is 119.99993. <\/p>\n<p>These functions take any expression F as input which can be implicitly converted to float.  The output of these functions is a floating point number.<\/p>\n<p>The examples below demonstrate various calls to the functions.<\/p>\n<pre class=\"lang:TSQL theme:familiar mark:1,2-3\" title=\"log10() vs power() - math functions\">\r\n--\r\n--  LOG10 versus POWER\r\n--\r\n\r\n-- Common logorithm base 10\r\nSELECT \r\n  LOG10(10) AS LOG1, \r\n  LOG10(100) AS LOG2, \r\n  LOG10(1000) AS LOG3, \r\n  LOG10(10000) AS LOG4, \r\n  LOG10(NULL) AS UNK;\r\nGO\r\n\r\n-- POWER &amp; LOG10 inversely related\r\nSELECT \r\n  POWER (10, LOG10(5)) AS MYNUMBER; \r\nGO\r\n\r\n<\/pre>\n<\/p>\n<p>The output from the test is listed below.<\/p>\n<pre class=\"lang:TSQL theme:epicgeeks\" title=\"output\">\r\noutput: \r\n\r\nLOG1   LOG2   LOG3   LOG4   UNK\r\n------ ------ ------ ------ ------\r\n1      2      3      4      NULL\r\n\r\nMYNUMBER\r\n----------\r\n5\r\n<\/span><\/pre>\n<\/p>\n<p>To summarize, the TSQL language has support for both the common logarithm and power 10 functions.  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am going to gain ground on completing my short articles on non-trigonometric Transaction SQL math functions. Most, if not all, of these functions have been in the product before the release of SQL Server 2005. I am very proud of my daughter making the advance math class in sixth grade. I am dedicating these blogs to her hard class work and love of the subject. Today, I will be exploring the LOG10() and POWER() functions. The common logarithm of number x is the power y to which 10 would&hellip;<\/p>\n","protected":false},"author":1,"featured_media":5430,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[814],"tags":[31,15,924,913,925,29],"class_list":["post-6414","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-very-short-articles","tag-database-developer","tag-john-f-miner-iii","tag-log10","tag-math-function","tag-power","tag-tsql"],"_links":{"self":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts\/6414","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6414"}],"version-history":[{"count":0,"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts\/6414\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/media\/5430"}],"wp:attachment":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6414"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}