{"id":2157,"date":"2022-01-27T00:57:08","date_gmt":"2022-01-26T19:27:08","guid":{"rendered":"https:\/\/batch-man.com\/?p=2157"},"modified":"2023-08-13T15:11:39","modified_gmt":"2023-08-13T09:41:39","slug":"ac","status":"publish","type":"post","link":"https:\/\/batch-man.com\/ac\/","title":{"rendered":"Evaluate complex math expressions in Batch with AC Function"},"content":{"rendered":"\n<p>One of the drawbacks of Batch is it&#8217;s lack of support for some <strong>complex math functions. <\/strong>This plugin, developed by <em><strong>Michael Bukowski<\/strong><\/em> can alleviate this restriction for you. While it has two dependencies, it is still very small (<strong>under 100kb<\/strong>) and unlocks powerful functions to use in your applications, including <strong>floating point<\/strong> and <strong>logarithm<\/strong> operations. In this article, we will discuss it&#8217;s benefits and use cases.<\/p>\n\n\n<h2 class=\"wp-block-heading has-text-align-center\" id=\"related-video\"><strong>RELATED VIDEO<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Can we even do this with CMD??? | AC Function 1.0 &amp; 1.1 Usage | Batch Programming\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/dEBtgeLYiP8?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n<h2 class=\"wp-block-heading has-text-align-center\" id=\"feature-comparison-ac-10-vs-11\"><strong>FEATURE COMPARISON &#8211; AC 1.0 VS 1.1<\/strong><\/h2>\n\n\n\n<p>AC 1.0 has a smaller feature set than AC 1.1 but is still useful for developers who do not want to utilize some of the more advanced features of this plugin. Both plugins still process floating point numeric values, but AC 1.1 unlocks a variety of math functions.<\/p>\n\n\n<h3 class=\"wp-block-heading has-text-align-center\" id=\"ac-11-table\">\n<strong>AC 1.<\/strong>1 <strong>TABLE<\/strong>\n<\/h3>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"312\" src=\"https:\/\/batch-man.com\/wp-content\/uploads\/2022\/01\/image-1-1024x312.png\" alt=\"\" class=\"wp-image-2161\" srcset=\"https:\/\/batch-man.com\/wp-content\/uploads\/2022\/01\/image-1-1024x312.png 1024w, https:\/\/batch-man.com\/wp-content\/uploads\/2022\/01\/image-1-300x91.png 300w, https:\/\/batch-man.com\/wp-content\/uploads\/2022\/01\/image-1-768x234.png 768w, https:\/\/batch-man.com\/wp-content\/uploads\/2022\/01\/image-1.png 1071w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n<h3 class=\"wp-block-heading has-text-align-center\" id=\"ac-10-table\">\n<strong>AC 1.0<\/strong> <strong>TABLE<\/strong>\n<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/batch-man.com\/wp-content\/uploads\/2022\/01\/image-2.png\" alt=\"\" class=\"wp-image-2162\" style=\"width:779px;height:215px\" width=\"779\" height=\"215\" srcset=\"https:\/\/batch-man.com\/wp-content\/uploads\/2022\/01\/image-2.png 611w, https:\/\/batch-man.com\/wp-content\/uploads\/2022\/01\/image-2-300x83.png 300w\" sizes=\"auto, (max-width: 779px) 100vw, 779px\" \/><\/figure>\n\n\n\n<p>As you can see, <strong>AC 1.1<\/strong> is the improved version of AC 1.0, but AC 1.0 is still mentioned in this article for compatibility purposes. Both allow you to utilize the above functions using <strong>floating point <\/strong>numbers to a high level of precision. <strong>AC<\/strong> uses the <strong>BC<\/strong> compiler for all of these functions. BC is an <strong><em>arbitrary precision numeric processing language<\/em><\/strong>, and this plugin allows batch to <strong>interface<\/strong> into it, hence why it is a dependency.<\/p>\n\n\n<h2 class=\"wp-block-heading has-text-align-center\" id=\"using-ac-in-your-projects-to-evaluate-expressions\">\n<strong>USING AC IN YOUR PROJECTS<\/strong> <strong>TO EVALUATE EXPRESSIONS<\/strong>\n<\/h2>\n\n\n\n<p>Let&#8217;s demonstrate how AC is effective by using it to calculate and round the value of <strong>Pi<\/strong> to three points of precision. Let&#8217;s assume we have it <strong>downloaded and linked to our path<\/strong>, so we can use it anywhere. There are two modes, specified by the first parameter. <strong>C <\/strong>in this case means we are running a <strong>calculation<\/strong> with the expression. <strong>R<\/strong> means we are rounding the expression (in the below case, to the third decimal point of precision). The below code block demonstrates it&#8217;s usage for calculating in this case. case:<\/p>\n\n\n<pre class=\"wp-block-code plover-prism prism-github-dark-theme language-clike\"><code>@echo off\nEcho. Calculating value of 'PI'\nCall AC C \"355\/113\" Pi\nEcho. Pi = %Pi%\nEcho.\nEcho. Rounding off 'Pi'\nCall AC R \"%Pi%\" 3 _New_Pi\nEcho. _New_Pi = %_New_pi%<\/code><\/pre>\n\n\n\n<p>As you can probably see, we are actually <strong>storing the result<\/strong> in a environment variable! This is one of the few plugins that will automatically store the result in an environment variable so that we are able to use it immediately, as if we had done <code><strong>set \/a<\/strong><\/code> (the original, limited method of math evaluation)<\/p>\n\n\n<pre class=\"wp-block-code plover-prism prism-github-dark-theme language-clike\"><code>CALL AC.BAT [MODE] [EXPRESSION] [OUTPUT ENV VARIABLE]<\/code><\/pre>\n\n\n\n<p>Let&#8217;s run that test program we gave above, and we should expect this output <strong>( <em>round(pi, 3)<\/em> ):<\/strong><\/p>\n\n\n<pre class=\"wp-block-code plover-prism prism-github-dark-theme language-clike\"><code>C:\\&gt;test.bat\nCalculating value of 'PI'\n Pi = \"3.1415929......\" \/\/ did not continue for sake of clarity\n\n Rounding off 'Pi'\n _New_Pi = 3.142<\/code><\/pre>\n\n\n\n<p>As you can see, this alone is <strong>extremely powerful<\/strong> for operations in CMD, as before floating point values were nearly impossible to implement. We can also utilize mathematical functions such as <strong>log_n, sin, cos and radian conversions<\/strong> in the proper form of <strong>func(x)<\/strong> right in the expression! I encourage you to try it out in your own project. An expression like: &#8220;<strong>1<\/strong><em><strong>+2+5^13+sin(4)+log_n(8)+sqrt(300)<\/strong><\/em>&#8221; is completely evaluated and returned using this plugin.<\/p>\n\n\n<h2 class=\"wp-block-heading has-text-align-center\" id=\"conclusiondownload\"><strong>CONCLUSION\/DOWNLOAD<\/strong><\/h2>\n\n\n\n<p>You can download this plugin on <a href=\"https:\/\/github.com\/Batch-Man\/AC-1.1\"><strong>our GitHub page<\/strong><\/a>, as well as see basic documentation and the table of functions I gave at the beginning of this article.  <em><strong>Michael Bukowski<\/strong><\/em>  is credited for developing this plugin as well as the creators of the <strong>BC and DC<\/strong> language. I hope this article has demonstrated how powerful this plugin can be for CMD applications, as these mathematical operations were once completely blocked off from use in the command-line. Thank you for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the drawbacks of Batch is it&#8217;s lack of support for some complex math functions. This plugin, developed by Michael Bukowski can alleviate this restriction for you. While it has two dependencies, it is still very small (under 100kb) and unlocks powerful functions to use in your applications, including floating point and logarithm operations. [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":2186,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[96,154,95,1],"tags":[99,5],"class_list":["post-2157","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-batch","category-plugin","category-programming","category-uncategorized","tag-batch","tag-kvc"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Evaluate complex math expressions in Batch with AC Function - Batch-Man<\/title>\n<meta name=\"description\" content=\"This plugin unlocks mathematical operations by creating an interface into BC for CMD\/Batch applications. Read this article to learn more.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/batch-man.com\/ac\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Evaluate complex math expressions in Batch with AC Function - Batch-Man\" \/>\n<meta property=\"og:description\" content=\"This plugin unlocks mathematical operations by creating an interface into BC for CMD\/Batch applications. Read this article to learn more.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/batch-man.com\/ac\/\" \/>\n<meta property=\"og:site_name\" content=\"Batch-Man\" \/>\n<meta property=\"article:published_time\" content=\"2022-01-26T19:27:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-13T09:41:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/batch-man.com\/wp-content\/uploads\/2022\/01\/br2.png\" \/>\n\t<meta property=\"og:image:width\" content=\"628\" \/>\n\t<meta property=\"og:image:height\" content=\"549\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"ZeekHalkyr\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"ZeekHalkyr\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/batch-man.com\/ac\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/batch-man.com\/ac\/\"},\"author\":{\"name\":\"ZeekHalkyr\",\"@id\":\"https:\/\/batch-man.com\/#\/schema\/person\/761368541dae8fcaa10dd4f2e3849e2c\"},\"headline\":\"Evaluate complex math expressions in Batch with AC Function\",\"datePublished\":\"2022-01-26T19:27:08+00:00\",\"dateModified\":\"2023-08-13T09:41:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/batch-man.com\/ac\/\"},\"wordCount\":547,\"commentCount\":1,\"image\":{\"@id\":\"https:\/\/batch-man.com\/ac\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/batch-man.com\/wp-content\/uploads\/2022\/01\/br2.png\",\"keywords\":[\"batch\",\"kvc\"],\"articleSection\":[\"Batch\",\"Plugin\",\"Programming\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/batch-man.com\/ac\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/batch-man.com\/ac\/\",\"url\":\"https:\/\/batch-man.com\/ac\/\",\"name\":\"Evaluate complex math expressions in Batch with AC Function - Batch-Man\",\"isPartOf\":{\"@id\":\"https:\/\/batch-man.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/batch-man.com\/ac\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/batch-man.com\/ac\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/batch-man.com\/wp-content\/uploads\/2022\/01\/br2.png\",\"datePublished\":\"2022-01-26T19:27:08+00:00\",\"dateModified\":\"2023-08-13T09:41:39+00:00\",\"author\":{\"@id\":\"https:\/\/batch-man.com\/#\/schema\/person\/761368541dae8fcaa10dd4f2e3849e2c\"},\"description\":\"This plugin unlocks mathematical operations by creating an interface into BC for CMD\/Batch applications. Read this article to learn more.\",\"breadcrumb\":{\"@id\":\"https:\/\/batch-man.com\/ac\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/batch-man.com\/ac\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/batch-man.com\/ac\/#primaryimage\",\"url\":\"https:\/\/batch-man.com\/wp-content\/uploads\/2022\/01\/br2.png\",\"contentUrl\":\"https:\/\/batch-man.com\/wp-content\/uploads\/2022\/01\/br2.png\",\"width\":628,\"height\":549},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/batch-man.com\/ac\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/batch-man.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Evaluate complex math expressions in Batch with AC Function\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/batch-man.com\/#website\",\"url\":\"https:\/\/batch-man.com\/\",\"name\":\"Batch-Man\",\"description\":\"When everybody thinks alike, nobody thinks at all\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/batch-man.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/batch-man.com\/#\/schema\/person\/761368541dae8fcaa10dd4f2e3849e2c\",\"name\":\"ZeekHalkyr\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/batch-man.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/batch-man.com\/wp-content\/uploads\/nsl_avatars\/d99bd13f907625cd0c2f9f3d39aba830.png\",\"contentUrl\":\"https:\/\/batch-man.com\/wp-content\/uploads\/nsl_avatars\/d99bd13f907625cd0c2f9f3d39aba830.png\",\"caption\":\"ZeekHalkyr\"},\"description\":\"I am a programmer and a computer hobbyist in the United States. I make articles about a variety of topics.\",\"url\":\"https:\/\/batch-man.com\/author\/zeek-2\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Evaluate complex math expressions in Batch with AC Function - Batch-Man","description":"This plugin unlocks mathematical operations by creating an interface into BC for CMD\/Batch applications. Read this article to learn more.","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:\/\/batch-man.com\/ac\/","og_locale":"en_US","og_type":"article","og_title":"Evaluate complex math expressions in Batch with AC Function - Batch-Man","og_description":"This plugin unlocks mathematical operations by creating an interface into BC for CMD\/Batch applications. Read this article to learn more.","og_url":"https:\/\/batch-man.com\/ac\/","og_site_name":"Batch-Man","article_published_time":"2022-01-26T19:27:08+00:00","article_modified_time":"2023-08-13T09:41:39+00:00","og_image":[{"width":628,"height":549,"url":"https:\/\/batch-man.com\/wp-content\/uploads\/2022\/01\/br2.png","type":"image\/png"}],"author":"ZeekHalkyr","twitter_card":"summary_large_image","twitter_misc":{"Written by":"ZeekHalkyr","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/batch-man.com\/ac\/#article","isPartOf":{"@id":"https:\/\/batch-man.com\/ac\/"},"author":{"name":"ZeekHalkyr","@id":"https:\/\/batch-man.com\/#\/schema\/person\/761368541dae8fcaa10dd4f2e3849e2c"},"headline":"Evaluate complex math expressions in Batch with AC Function","datePublished":"2022-01-26T19:27:08+00:00","dateModified":"2023-08-13T09:41:39+00:00","mainEntityOfPage":{"@id":"https:\/\/batch-man.com\/ac\/"},"wordCount":547,"commentCount":1,"image":{"@id":"https:\/\/batch-man.com\/ac\/#primaryimage"},"thumbnailUrl":"https:\/\/batch-man.com\/wp-content\/uploads\/2022\/01\/br2.png","keywords":["batch","kvc"],"articleSection":["Batch","Plugin","Programming"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/batch-man.com\/ac\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/batch-man.com\/ac\/","url":"https:\/\/batch-man.com\/ac\/","name":"Evaluate complex math expressions in Batch with AC Function - Batch-Man","isPartOf":{"@id":"https:\/\/batch-man.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/batch-man.com\/ac\/#primaryimage"},"image":{"@id":"https:\/\/batch-man.com\/ac\/#primaryimage"},"thumbnailUrl":"https:\/\/batch-man.com\/wp-content\/uploads\/2022\/01\/br2.png","datePublished":"2022-01-26T19:27:08+00:00","dateModified":"2023-08-13T09:41:39+00:00","author":{"@id":"https:\/\/batch-man.com\/#\/schema\/person\/761368541dae8fcaa10dd4f2e3849e2c"},"description":"This plugin unlocks mathematical operations by creating an interface into BC for CMD\/Batch applications. Read this article to learn more.","breadcrumb":{"@id":"https:\/\/batch-man.com\/ac\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/batch-man.com\/ac\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/batch-man.com\/ac\/#primaryimage","url":"https:\/\/batch-man.com\/wp-content\/uploads\/2022\/01\/br2.png","contentUrl":"https:\/\/batch-man.com\/wp-content\/uploads\/2022\/01\/br2.png","width":628,"height":549},{"@type":"BreadcrumbList","@id":"https:\/\/batch-man.com\/ac\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/batch-man.com\/"},{"@type":"ListItem","position":2,"name":"Evaluate complex math expressions in Batch with AC Function"}]},{"@type":"WebSite","@id":"https:\/\/batch-man.com\/#website","url":"https:\/\/batch-man.com\/","name":"Batch-Man","description":"When everybody thinks alike, nobody thinks at all","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/batch-man.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/batch-man.com\/#\/schema\/person\/761368541dae8fcaa10dd4f2e3849e2c","name":"ZeekHalkyr","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/batch-man.com\/#\/schema\/person\/image\/","url":"https:\/\/batch-man.com\/wp-content\/uploads\/nsl_avatars\/d99bd13f907625cd0c2f9f3d39aba830.png","contentUrl":"https:\/\/batch-man.com\/wp-content\/uploads\/nsl_avatars\/d99bd13f907625cd0c2f9f3d39aba830.png","caption":"ZeekHalkyr"},"description":"I am a programmer and a computer hobbyist in the United States. I make articles about a variety of topics.","url":"https:\/\/batch-man.com\/author\/zeek-2\/"}]}},"_links":{"self":[{"href":"https:\/\/batch-man.com\/wp-json\/wp\/v2\/posts\/2157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/batch-man.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/batch-man.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/batch-man.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/batch-man.com\/wp-json\/wp\/v2\/comments?post=2157"}],"version-history":[{"count":6,"href":"https:\/\/batch-man.com\/wp-json\/wp\/v2\/posts\/2157\/revisions"}],"predecessor-version":[{"id":6148,"href":"https:\/\/batch-man.com\/wp-json\/wp\/v2\/posts\/2157\/revisions\/6148"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/batch-man.com\/wp-json\/wp\/v2\/media\/2186"}],"wp:attachment":[{"href":"https:\/\/batch-man.com\/wp-json\/wp\/v2\/media?parent=2157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/batch-man.com\/wp-json\/wp\/v2\/categories?post=2157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/batch-man.com\/wp-json\/wp\/v2\/tags?post=2157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}