{"id":62243,"date":"2022-01-10T07:00:54","date_gmt":"2022-01-10T06:00:54","guid":{"rendered":"https:\/\/drafts.code-maze.com\/?p=62167"},"modified":"2022-01-10T07:48:27","modified_gmt":"2022-01-10T06:48:27","slug":"csharp-math","status":"publish","type":"post","link":"https:\/\/code-maze.com\/csharp-math\/","title":{"rendered":"Math Class in C#"},"content":{"rendered":"<p>In this article, we are going to describe the Math class in C#. The Math class in C# contains lots of useful static methods for performing all sorts of calculations. We&#8217;ll briefly describe all the methods in the library with some examples, so it will be quite a long article, but you can use it as a reference as well.<\/p>\n<div style=\"padding: 20px; border-left: 5px #dc2323 solid; display: block; margin-bottom: 20px; box-shadow: 1px 1px 5px 0px lightgrey;\">To download the source code for this article, you can visit our <a href=\"https:\/\/github.com\/CodeMazeBlog\/CodeMazeGuides\/tree\/main\/numbers-csharp\/MathInCSharp\" target=\"_blank\" rel=\"nofollow noopener\">GitHub repository<\/a>.<\/div>\n<p>Let&#8217;s see what we have at our disposal.<\/p>\n<h2><a id=\"basic\"><\/a>Basic Math Functions<\/h2>\n<p>The first set of functions contains the most commonly used functions like the square root and calculating the maximum or minimum of two numbers.<\/p>\n<h3>Abs<\/h3>\n<p>The <code>Abs<\/code> method returns the absolute value of the given argument:<br \/>\n<code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.Abs(-1); \/\/ returns 1<\/code><\/p>\n<p>Similar to many other methods we will see, there are several overloads of this method: It can accept a decimal, double, float, int, long, nint, sbyte or short, and returns the respective type.<\/p>\n<h3>Max<\/h3>\n<p>The <code>Max<\/code> method returns the maximum value of the two arguments:<br \/>\n<code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.Max(3.7, 1.8);\/\/ returns\u00a0 3.7<\/code><\/p>\n<p>It can accept a decimal, double, float, int, long, nint, sbyte, short, byte, uint, ulong, or ushort.<\/p>\n<h3>MaxMagnitude<\/h3>\n<p>The <code>MaxMagnitude<\/code> method returns the larger magnitude of two doubles:<br \/>\n<code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.MaxMagnitude(-10.0, 3.0); \/\/returns -10<\/code><\/p>\n<h3>Min<\/h3>\n<p>The <code>Min<\/code> method returns the minimum value of the two arguments:<br \/>\n<code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.Min(5, 10); \/\/ returns 5<\/code><\/p>\n<p>It can accept a decimal, double, float, int, long, nint, sbyte, short, byte, uint, long, or ushort.<\/p>\n<h3>MinMagnitude<\/h3>\n<p>The <code>MinMagnitude<\/code> method returns the smaller magnitude of two doubles:<br \/>\n<code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.MinMagnitude(-10.0, 3.0); \/\/returns 3<\/code><\/p>\n<h3>BigMul<\/h3>\n<p>The <code>BigMul<\/code> method produces the full product of two numbers.\u00a0<\/p>\n<p>As the result of multiplying two int numbers won&#8217;t fit into an int, the result is a long:<br \/>\n<code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">long result = Math.BigMul(Int32.MaxValue, Int32.MaxValue); \/\/ returns 4611686014132420609<\/code><\/p>\n<p>There are also overloads to multiply long values and ulong values. In this case, the result will not fit into a long, so the result is spread of the return argument and an out argument, here we show it for the long case:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">long lowerBits = 0, arg1 = long.MaxValue, arg2 = long.MaxValue;\r\nlong higherBits = Math.BigMul(arg1, arg2, out lowerBits);<\/pre>\n<h3>BitIncrement, BitDecrement<\/h3>\n<p>Returns the next larger (resp. smaller) double value that compares greater (resp. smaller) than the given argument:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">bool lhsIsSmaller = Math.BitDecrement(1.123) &lt; 1.123; \/\/ returns true\r\nbool rhsIsSmaller = Math.BitIncrement(1.123) &gt; 1.123; \/\/ returns true<\/pre>\n<h3>Cbrt<\/h3>\n<p>Returns the cube root of the given double argument:<br \/>\n<code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.Cbrt(8.0); \/\/returns 2<\/code><\/p>\n<h3>CopySign<\/h3>\n<p>Returns a value with the magnitude of the first, and the sign of the second double argument:<br \/>\n<code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.CopySign(10.0, -2.0); \/\/ returns -10<\/code><\/p>\n<h3>DivRem<\/h3>\n<p>This method performs division with remainder, and returns both the quotient and the remainder as a tuple:<br \/>\n<code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">var (quotient, rem) = Math.DivRem(15, 7); \/\/ (quotient, rem) is (2, 1)<\/code><\/p>\n<p>The input can be byte, int, long, nint, nuint, sbyte, short, uint, ulong, or ushort.\u00a0<\/p>\n<h3>FusedMultiplyAdd<\/h3>\n<p>Returns <code>(x*y)+z<\/code>, rounded as one operation. Contrary to doing these operations separately, the intermediate result is not rounded so this will give more accurate results. This can be beneficial in applications where the loss of precision due to many intermediate steps can be an issue:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.FusedMultiplyAdd(1.0, 2.0, 3.0); \/\/ returns 1*2 + 3 = 5<\/code><\/p>\n<p>Both the input values and the output values are doubles.<\/p>\n<h3>IEEERemainder<\/h3>\n<p>This method returns the remainder resulting from the division of a specified number by another specified number, using the following formula. Both input and output are doubles:<\/p>\n<p><code>IEEERemainder = dividend - (divisor * Math.Round(dividend \/ divisor)) <\/code><\/p>\n<p>The result is different from the <code>%<\/code> operator:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.IEEERemainder(3,\u00a0 2); \/\/returns -1\r\nvar val = 3 % 2 \/\/ val is 1<\/pre>\n<h3>ReciprocalEstimate, ReciprocalSqrtEstimate<\/h3>\n<p>This method returns an estimate of the reciprocal of a specified <code>double<\/code> or the reciprocal square root of a given value:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.ReciprocalEstimate(2.0);\/\/ returns 0.5\r\nMath.ReciprocalSqrtEstimate(4.0); \/\/ returns 1\/(sqrt(4)) = 1\/2 = 0.5<\/pre>\n<p>Unless it is an ARM64 architecture, this simply returns 1.0\/value resp. 1.0\/sqrt(value). In the case of an ARM64 architecture, it performs a Newton-Raphson iteration to calculate it, which might be more efficient.<\/p>\n<h3>Sign<\/h3>\n<p>This method returns the sign of a given number, i.e. returns -1 if the value is less than zero, 0 if it is zero, and +1 if it is greater than zero:<br \/>\n<code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.Sign(-5.0); \/\/ returns -1<\/code><\/p>\n<p>The input can be a double, int, float, decimal, long, nint, sbyte, or short. The output is always an int.<\/p>\n<h3>Sqrt<\/h3>\n<p>Returns the square root of a given double. When it is negative, it returns <code>double.NaN<\/code>:<br \/>\n<code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.Sqrt(4.0); \/\/ returns 2<\/code><\/p>\n<h2><a id=\"exponential\"><\/a>Exponential and Logarithmic Functions<\/h2>\n<p>The Math class in C# provides lots of methods to work with exponentials and logarithms.<\/p>\n<h3>Exp<\/h3>\n<p>Returns the mathematical constant <code>e<\/code> raised to the given power:<br \/>\n<code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.Exp(1); \/\/ returns 2.71..<\/code><\/p>\n<p>The input and output are double.<\/p>\n<h3>ILogB<\/h3>\n<p>This method returns the base 2 integer logarithm of a specified double number, i.e. (int)log2(val):<br \/>\n<code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.ILogB(9.0); \/\/ returns 3<\/code><\/p>\n<h3>Log<\/h3>\n<p>Returns the natural logarithm of a given double value. When the given value is 0, it returns <code>double.NegativeInfinity<\/code> and for negative values, it returns <code>double.NaN<\/code>. You can also specify an optional argument to use another base:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.Log(Math.Exp(4.0));\/\/returns 4\r\nMath.Log(100, 10); \/\/ returns 2<\/pre>\n<h3>Log10, Log2<\/h3>\n<p>Returns the 10 log resp. 2 log of a given double value. When the given value is 0, it returns <code>double.NegativeInfinity<\/code>, and for negative values, it returns <code>double.NaN<\/code>:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.Log10(1000); \/\/ returns 3\r\nMath.Log2(16); \/\/ returns 4<\/pre>\n<h3>Pow<\/h3>\n<p>Returns a specified number raised to another specified number. Both input and output are doubles:<br \/>\n<code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.Pow(3.0, 3.0); \/\/ returns 3^3 = 27<\/code><\/p>\n<h3>ScaleB<\/h3>\n<p>Returns x*2^n, where x is a double and n is an integer. This can be done efficiently:<br \/>\n<code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.ScaleB(3.0, 2); \/\/ returns 3.0*4 = 12<\/code><\/p>\n<h2><a id=\"trig\"><\/a>Trigonometric Functions<\/h2>\n<p>All the common (and less common) trigonometric methods are available in the <code>Math<\/code> class as well:<\/p>\n<h3>Sin, Cos, Tan<\/h3>\n<p>These methods return the sine, cosine, or tangent resp. of a given double angle, measures in radians:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.Sin(Math.PI); \/\/ returns 0\r\nMath.Cos(Math.PI); \/\/ returns -1\r\nMath.Tan(Math.PI); \/\/ returns 0<\/pre>\n<h3>Asin, Acos, Atan<\/h3>\n<p>These are the inverse sine, cosine, and tangent.<\/p>\n<p>The Asin returns a value in the range-0.5PI till 0.5PI, double.NaN if the input is greater than 1, less than -1<\/p>\n<p>The Acos returns a value in the range 0 till PI.<\/p>\n<p>The Atan returns a value in the range -0.5PI till 0.5PI. If the given value is <code>double.PositiveInfinity<\/code>, it returns <code>0.5*Math.PI<\/code> rounded to the nearest double:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.Asin(1); \/\/ returns Math.PI*0.5\r\nMath.Acos(0); \/\/ returns Math.PI\r\nMath.Atan(double.PositiveInfinity); \/\/ returns 1.5707...<\/pre>\n<h3>Sinh, Cosh, Tanh<\/h3>\n<p>These methods return the hyperbolic sine, cosine, and tangent of a given double value:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.Sinh(0); \/\/ returns 0\r\nMath.Cosh(0.0); \/\/ returns 1\r\nMath.Tanh(0.0); \/\/returns 0<\/pre>\n<h3>Asinh, Acosh, Atanh<\/h3>\n<p>These methods return the inverse hyperbolic sine, cosine, and tangent of a given double value:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.Asinh(0.0); \/\/ returns 0\r\nMath.Acosh(1.0); \/\/ returns 0\r\nMath.Atanh(0.0); \/\/ returns 0<\/pre>\n<h2><a id=\"rounding\"><\/a>Rounding and Related Functions<\/h2>\n<p>There are several different rounding related methods, which we organized under this section:<\/p>\n<h3>Ceiling<\/h3>\n<p>Returns the smallest integral value that is greater than or equal to the specified number. The input and output can be double or decimal:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.Ceiling(3.001); \/\/ returns 4\r\nMath.Ceiling(1.0); \/\/ returns 1<\/pre>\n<h3>Clamp<\/h3>\n<p>Returns the value clamped to a specified min and max value. If the value lies between the min and max, it simply returns the value. Otherwise, it returns either min or max. The input types can be decimal, double, float, int, long, nint, sbyte, short, byte, uint, ulong, or short:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.Clamp(0.0, -1.0, 2.0); \/\/ returns 0\r\nMath.Clamp(-10.0, -1.0, 2.0); \/\/ returns -1\r\nMath.Clamp(10.0, -1.0, 2.0); \/\/ returns 2<\/pre>\n<h3>Floor<\/h3>\n<p>Returns the largest integral value that is smaller than or equal to the specified number. The input and output can be double or decimal:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.Floor(1.0); \/\/ returns 1\r\nMath.Floor(1.3); \/\/ returns 1\r\nMath.Floor(1.999); \/\/ returns 1<\/pre>\n<h3>Round<\/h3>\n<p>Returns the closest integral value. The input type can be either double or decimal. One can also specify to how many decimal digits the specified value needs to be rounded to:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.Round(1.49); \/\/ returns 1\r\nMath.Round(1.49, 1); \/\/ returns 1.5<\/pre>\n<h3>Truncate<\/h3>\n<p>Returns an integral part of a given value. This is different than the other methods mentioned in this section, as it might round up or down depending on the sign of the value. The value itself can be double or decimal:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">Math.Truncate(-2.2); \/\/ returns -2\r\nMath.Truncate(2.2); \/\/ returns 2<\/pre>\n<h2><a id=\"fields\"><\/a>Fields<\/h2>\n<p>There are several important mathematical constants that are represented as fields in the Math class in C#.<\/p>\n<h3>PI<\/h3>\n<p>The mathematical constant Pi (\u03c0):<br \/>\n<code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">public const double PI = 3.1415926535897931;<\/code><\/p>\n<h3>E<\/h3>\n<p>The mathematical constant e, i.e. the base of the natural logarithm:<br \/>\n<code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">public const double E = 2.7182818284590451;<\/code><\/p>\n<h3>Tau<\/h3>\n<p>This constant equals 2\u03c0. It has recently been introduced (since .NET 5):<br \/>\n<code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">public const double Tau = 6.2831853071795862;<\/code><\/p>\n<h2><a id=\"conclusion\"><\/a>Conclusion<\/h2>\n<p>We&#8217;ve seen that there are lots of mathematical methods in the Math class in C#, which can help you a lot if you are writing mathematical or scientific software.\u00a0<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we are going to describe the Math class in C#. The Math class in C# contains lots of useful static methods for performing all sorts of calculations. We&#8217;ll briefly describe all the methods in the library with some examples, so it will be quite a long article, but you can use it [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":62189,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[12],"tags":[995,997,996],"class_list":["post-62243","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-csharp","tag-math","tag-math-class","tag-operations","et-has-post-format-content","et_post_format-et-post-format-standard"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Math Class in C# - Code Maze<\/title>\n<meta name=\"description\" content=\"A guide to the C# Math class with many examples on how to use it. Basic, exponential and trigometric functions are discussed.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/code-maze.com\/csharp-math\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Math Class in C# - Code Maze\" \/>\n<meta property=\"og:description\" content=\"A guide to the C# Math class with many examples on how to use it. Basic, exponential and trigometric functions are discussed.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/code-maze.com\/csharp-math\/\" \/>\n<meta property=\"og:site_name\" content=\"Code Maze\" \/>\n<meta property=\"article:published_time\" content=\"2022-01-10T06:00:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-01-10T06:48:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-csharp.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1100\" \/>\n\t<meta property=\"og:image:height\" content=\"620\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Code Maze\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/CodeMazeBlog\" \/>\n<meta name=\"twitter:site\" content=\"@CodeMazeBlog\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Code Maze\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"BlogPosting\"],\"@id\":\"https:\/\/code-maze.com\/csharp-math\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/code-maze.com\/csharp-math\/\"},\"author\":{\"name\":\"Code Maze\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/person\/09d29b223012c8e94a68ba62861d0b04\"},\"headline\":\"Math Class in C#\",\"datePublished\":\"2022-01-10T06:00:54+00:00\",\"dateModified\":\"2022-01-10T06:48:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/code-maze.com\/csharp-math\/\"},\"wordCount\":1159,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/code-maze.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/code-maze.com\/csharp-math\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-csharp.png\",\"keywords\":[\"math\",\"math class\",\"operations\"],\"articleSection\":[\"C#\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/code-maze.com\/csharp-math\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/code-maze.com\/csharp-math\/\",\"url\":\"https:\/\/code-maze.com\/csharp-math\/\",\"name\":\"Math Class in C# - Code Maze\",\"isPartOf\":{\"@id\":\"https:\/\/code-maze.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/code-maze.com\/csharp-math\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/code-maze.com\/csharp-math\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-csharp.png\",\"datePublished\":\"2022-01-10T06:00:54+00:00\",\"dateModified\":\"2022-01-10T06:48:27+00:00\",\"description\":\"A guide to the C# Math class with many examples on how to use it. Basic, exponential and trigometric functions are discussed.\",\"breadcrumb\":{\"@id\":\"https:\/\/code-maze.com\/csharp-math\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/code-maze.com\/csharp-math\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/code-maze.com\/csharp-math\/#primaryimage\",\"url\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-csharp.png\",\"contentUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-csharp.png\",\"width\":1100,\"height\":620,\"caption\":\"C# Development\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/code-maze.com\/csharp-math\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/code-maze.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Math Class in C#\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/code-maze.com\/#website\",\"url\":\"https:\/\/code-maze.com\/\",\"name\":\"Code Maze\",\"description\":\"Learn. Code. Succeed.\",\"publisher\":{\"@id\":\"https:\/\/code-maze.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/code-maze.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/code-maze.com\/#organization\",\"name\":\"Code Maze\",\"url\":\"https:\/\/code-maze.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png\",\"contentUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png\",\"width\":3511,\"height\":3510,\"caption\":\"Code Maze\"},\"image\":{\"@id\":\"https:\/\/code-maze.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/CodeMazeBlog\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/person\/09d29b223012c8e94a68ba62861d0b04\",\"name\":\"Code Maze\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez-150x150.png\",\"contentUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez-150x150.png\",\"caption\":\"Code Maze\"},\"description\":\"This is the standard author on the site. Most articles are published by individual authors, with their profiles, but when several authors have contributed, we publish collectively as a part of this profile.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/company\/codemaze\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/CodeMazeBlog\"],\"url\":\"https:\/\/code-maze.com\/author\/codemazecontributor\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Math Class in C# - Code Maze","description":"A guide to the C# Math class with many examples on how to use it. Basic, exponential and trigometric functions are discussed.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/code-maze.com\/csharp-math\/","og_locale":"en_US","og_type":"article","og_title":"Math Class in C# - Code Maze","og_description":"A guide to the C# Math class with many examples on how to use it. Basic, exponential and trigometric functions are discussed.","og_url":"https:\/\/code-maze.com\/csharp-math\/","og_site_name":"Code Maze","article_published_time":"2022-01-10T06:00:54+00:00","article_modified_time":"2022-01-10T06:48:27+00:00","og_image":[{"width":1100,"height":620,"url":"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-csharp.png","type":"image\/png"}],"author":"Code Maze","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/CodeMazeBlog","twitter_site":"@CodeMazeBlog","twitter_misc":{"Written by":"Code Maze","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","BlogPosting"],"@id":"https:\/\/code-maze.com\/csharp-math\/#article","isPartOf":{"@id":"https:\/\/code-maze.com\/csharp-math\/"},"author":{"name":"Code Maze","@id":"https:\/\/code-maze.com\/#\/schema\/person\/09d29b223012c8e94a68ba62861d0b04"},"headline":"Math Class in C#","datePublished":"2022-01-10T06:00:54+00:00","dateModified":"2022-01-10T06:48:27+00:00","mainEntityOfPage":{"@id":"https:\/\/code-maze.com\/csharp-math\/"},"wordCount":1159,"commentCount":0,"publisher":{"@id":"https:\/\/code-maze.com\/#organization"},"image":{"@id":"https:\/\/code-maze.com\/csharp-math\/#primaryimage"},"thumbnailUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-csharp.png","keywords":["math","math class","operations"],"articleSection":["C#"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/code-maze.com\/csharp-math\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/code-maze.com\/csharp-math\/","url":"https:\/\/code-maze.com\/csharp-math\/","name":"Math Class in C# - Code Maze","isPartOf":{"@id":"https:\/\/code-maze.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/code-maze.com\/csharp-math\/#primaryimage"},"image":{"@id":"https:\/\/code-maze.com\/csharp-math\/#primaryimage"},"thumbnailUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-csharp.png","datePublished":"2022-01-10T06:00:54+00:00","dateModified":"2022-01-10T06:48:27+00:00","description":"A guide to the C# Math class with many examples on how to use it. Basic, exponential and trigometric functions are discussed.","breadcrumb":{"@id":"https:\/\/code-maze.com\/csharp-math\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/code-maze.com\/csharp-math\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/code-maze.com\/csharp-math\/#primaryimage","url":"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-csharp.png","contentUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-csharp.png","width":1100,"height":620,"caption":"C# Development"},{"@type":"BreadcrumbList","@id":"https:\/\/code-maze.com\/csharp-math\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/code-maze.com\/"},{"@type":"ListItem","position":2,"name":"Math Class in C#"}]},{"@type":"WebSite","@id":"https:\/\/code-maze.com\/#website","url":"https:\/\/code-maze.com\/","name":"Code Maze","description":"Learn. Code. Succeed.","publisher":{"@id":"https:\/\/code-maze.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/code-maze.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/code-maze.com\/#organization","name":"Code Maze","url":"https:\/\/code-maze.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/code-maze.com\/#\/schema\/logo\/image\/","url":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png","contentUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png","width":3511,"height":3510,"caption":"Code Maze"},"image":{"@id":"https:\/\/code-maze.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/CodeMazeBlog"]},{"@type":"Person","@id":"https:\/\/code-maze.com\/#\/schema\/person\/09d29b223012c8e94a68ba62861d0b04","name":"Code Maze","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/code-maze.com\/#\/schema\/person\/image\/","url":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez-150x150.png","contentUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez-150x150.png","caption":"Code Maze"},"description":"This is the standard author on the site. Most articles are published by individual authors, with their profiles, but when several authors have contributed, we publish collectively as a part of this profile.","sameAs":["https:\/\/www.linkedin.com\/company\/codemaze\/","https:\/\/x.com\/https:\/\/twitter.com\/CodeMazeBlog"],"url":"https:\/\/code-maze.com\/author\/codemazecontributor\/"}]}},"_links":{"self":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts\/62243","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/comments?post=62243"}],"version-history":[{"count":5,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts\/62243\/revisions"}],"predecessor-version":[{"id":63249,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts\/62243\/revisions\/63249"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/media\/62189"}],"wp:attachment":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/media?parent=62243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/categories?post=62243"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/tags?post=62243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}