{"id":470,"date":"2016-01-03T18:29:58","date_gmt":"2016-01-03T18:29:58","guid":{"rendered":"http:\/\/mathparser.org\/?page_id=470"},"modified":"2024-09-21T11:35:29","modified_gmt":"2024-09-21T11:35:29","slug":"user-defined-constants","status":"publish","type":"page","link":"https:\/\/mathparser.org\/mxparser-tutorial\/user-defined-constants\/","title":{"rendered":"User defined constants"},"content":{"rendered":"\n<h6 class=\"wp-block-heading\">TO SUPPORT MY WORK, ORDER A COMMERCIAL LICENSE<\/h6>\n\n\n<div class='wpi_twin_buttons wpi_twin_button_1977'><a href='https:\/\/mathparser.org\/order-commercial-license\/' class='wpi_left_button wpi_designer_button wpi_shadow wpi_shadow_ wpi_designer_button_preset_242 wpi_icon wpi_icon_fa-shopping-cart   ' target='_blank' ><i class=''><\/i><span class='wpi_text'>ORDER Page<\/span><span class='wpi_or_txt'>or<\/span><\/a><a href='https:\/\/payhip.com\/INFIMA' class='wpi_right_button wpi_designer_button wpi_shadow wpi_shadow_ wpi_designer_button_preset_217 wpi_icon wpi_icon_fa-shopping-cart   ' target='_blank' ><i class=''><\/i><span class='wpi_text'>INFIMA Store<\/span><\/a><\/div>\n\n\n\n<h6 class=\"wp-block-heading\">THANK YOU!<\/h6>\n\n\n\n<h4 class=\"wp-block-heading\">The tutorial consists of more than 200 live examples from 50 sections given separately for JAVA, C# and C++. Each of the examples can be copied and run on your own environment. In addition, mXparser provides an extensive collection of over 500 built-in math functions, expressions and symbols. Familiarize yourself with the scope and the syntax. Live testing is the best way to learn. Good luck! \ud83d\ude42<\/h4>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><a href=\"https:\/\/mathparser.org\/wp-content\/uploads\/2024\/09\/mxparser-logo-700.png\"><img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"700\" src=\"https:\/\/mathparser.org\/wp-content\/uploads\/2024\/09\/mxparser-logo-700.png\" alt=\"\" class=\"wp-image-22231\" style=\"width:263px;height:auto\" srcset=\"https:\/\/mathparser.org\/wp-content\/uploads\/2024\/09\/mxparser-logo-700.png 700w, https:\/\/mathparser.org\/wp-content\/uploads\/2024\/09\/mxparser-logo-700-300x300.png 300w, https:\/\/mathparser.org\/wp-content\/uploads\/2024\/09\/mxparser-logo-700-150x150.png 150w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/a><\/figure>\n<\/div>\n\n\n<iframe loading=\"lazy\" width=\"600\" height=\"371\" seamless=\"\" frameborder=\"0\" scrolling=\"no\" src=\"https:\/\/docs.google.com\/spreadsheets\/d\/e\/2PACX-1vS2EPIDjq_ruk0PXaEJ-9qrGg41u4EidBkQ2JawtswZBCDXGnDj4wS7OI0X-K5TVyUFg5Cg9Szq8VDB\/pubchart?oid=598931925&amp;format=interactive\"><\/iframe>\n\n\n\n<p class=\"has-text-align-center\"><a href='https:\/\/mathparser.org\/mxparser-tutorial\/' onclick='' class='wpi_designer_button   wpi_shadow wpi_shadow_ wpi_designer_button_preset_247 wpi_icon wpi_icon_code wpi_icon_left  ' target='' rel=''><i class=''><\/i><span class='wpi_text'>Tutorial<\/span><\/a> <a href='https:\/\/mathparser.org\/mxparser-math-collection\/' onclick='' class='wpi_designer_button   wpi_shadow wpi_shadow_ wpi_designer_button_preset_247 wpi_icon wpi_icon_fa-graduation-cap wpi_icon_left  ' target='' rel=''><i class=''><\/i><span class='wpi_text'>Math Collection<\/span><\/a> <a href='https:\/\/mathparser.org\/api\/' onclick='' class='wpi_designer_button   wpi_shadow wpi_shadow_ wpi_designer_button_preset_247 wpi_icon wpi_icon_book wpi_icon_left  ' target='' rel=''><i class=''><\/i><span class='wpi_text'>API spec<\/span><\/a> <a href='https:\/\/mathparser.org\/mxparser-downloads\/' onclick='' class='wpi_designer_button   wpi_shadow wpi_shadow_ wpi_designer_button_preset_247 wpi_icon wpi_icon_download wpi_icon_left  ' target='' rel=''><i class=''><\/i><span class='wpi_text'>Download<\/span><\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Below is the code for JAVA, C# (the code for C# is almost identical) and C++. To copy the code, double-click inside the frame.<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">Java\/C# code<\/h5>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\n\/\/ JAVA: import org.mariuszgromada.math.mxparser.*;\n\/\/ C#: using org.mariuszgromada.math.mxparser;\n\/\/ ...\nConstant a = new Constant(\"a\", 5);\nConstant b = new Constant(\"b = 10\");        \nExpression e = new Expression(\"a+b\", a, b);\n\nmXparser.consolePrintln(a.getConstantName() + \" = \" + a.getConstantValue());\nmXparser.consolePrintln(b.getConstantName() + \" = \" + b.getConstantValue());\nmXparser.consolePrintln(\"Res: \" + e.getExpressionString() + \" = \" + e.calculate());\n<\/pre><\/div>\n\n\n<h5 class=\"wp-block-heading\">C++ code<\/h5>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n#include &quot;org\/mariuszgromada\/math\/mxparser.hpp&quot;\n\/\/ ...\nConstantPtr a = new_Constant(&quot;a&quot;, 5);\nConstantPtr b = new_Constant(&quot;b = 10&quot;);\nExpressionPtr e = new_Expression(&quot;a+b&quot;, a, b);\n\nmXparser::consolePrintln(a-&gt;getConstantName() + &quot; = &quot; + a-&gt;getConstantValue());\nmXparser::consolePrintln(b-&gt;getConstantName() + &quot; = &quot; + b-&gt;getConstantValue());\nmXparser::consolePrintln(&quot;Res: &quot; + e-&gt;getExpressionString() + &quot; = &quot; + e-&gt;calculate());\n<\/pre><\/div>\n\n\n<h5 class=\"wp-block-heading\">Code result<\/h5>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\n&#x5B;mXparser-v.5.2.1] a = 5.0\n&#x5B;mXparser-v.5.2.1] b = 10.0\n&#x5B;mXparser-v.5.2.1] Res: a+b = 15.0\n<\/pre><\/div>\n\n\n<h6 class=\"wp-block-heading\"><a style=\"\" href=\"https:\/\/www.nuget.org\/packages\/MathParser.org-mXparser\/\" target=\"_blank\" rel=\"noreferrer noopener\">Nuget &#8211; Package Manager (<\/a><strong><a href=\"https:\/\/www.nuget.org\/packages\/MathParser.org-mXparser\/\" target=\"_blank\" rel=\"noreferrer noopener\">C#, F#, Visual Basic, &#8230;)<\/a><\/strong><\/h6>\n\n\n\n<p class=\"copy-cliboard has-background\" style=\"background-color:#404040\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-white-color\"><code>Install-Package <\/code><\/mark><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-yellow-color\">MathParser.org-mXparser<\/mark><\/strong><\/code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-white-color\"><code> -Version <\/code><\/mark><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-yellow-color\"><strong>6.1.0<\/strong><\/mark><\/code><\/p>\n\n\n\n<p><strong><a rel=\"noreferrer noopener\" href=\"https:\/\/www.nuget.org\/packages\/MathParser.org-mXparser\/\" target=\"_blank\">Nuget &#8211; .NET CLI<\/a><\/strong><\/p>\n\n\n\n<p class=\"copy-cliboard has-background\" style=\"background-color:#404040\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-white-color\"><code>dotnet add package <\/code><\/mark><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-yellow-color\">MathParser.org-mXparser<\/mark><\/strong><\/code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-white-color\"><code> --version <\/code><\/mark><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-yellow-color\">6.1.0<\/mark><\/strong><\/code><\/p>\n\n\n\n<p><strong><a rel=\"noreferrer noopener\" href=\"https:\/\/www.nuget.org\/packages\/MathParser.org-mXparser\/\" target=\"_blank\">Nuget &#8211; Package Reference<\/a><\/strong><\/p>\n\n\n\n<p class=\"copy-cliboard has-background\" style=\"background-color:#404040\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-white-color\"><code>&lt;PackageReference Include=<\/code><\/mark><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-yellow-color\">\"MathParser.org-mXparser\"<\/mark><\/strong><\/code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-white-color\"><code> Version=<\/code><\/mark><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-yellow-color\">\"6.1.0\"<\/mark><\/strong><\/code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-white-color\"><code>\/&gt;<\/code><\/mark><\/p>\n\n\n\n<h6 class=\"wp-block-heading\"><strong><a href=\"https:\/\/search.maven.org\/artifact\/org.mariuszgromada.math\/MathParser.org-mXparser\/5.0.2\/jar\" target=\"_blank\" rel=\"noreferrer noopener\">Maven &#8211; Dependency (Java, Kotlin, Scala, Groovy, &#8230;)<\/a><\/strong><\/h6>\n\n\n\n<p class=\"copy-cliboard has-background\" style=\"background-color:#404040\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-white-color\"><code>&lt;dependency&gt;<br>&lt;groupid&gt;<\/code><\/mark><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-yellow-color\">org.mariuszgromada.math<\/mark><\/strong><\/code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-white-color\"><code>&lt;\/groupid&gt;<br>&lt;artifactid&gt;<\/code><\/mark><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-yellow-color\">MathParser.org-mXparser<\/mark><\/strong><\/code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-white-color\"><code>&lt;\/artifactid&gt;<br>&lt;version&gt;<\/code><\/mark><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-yellow-color\">6.1.0<\/mark><\/strong><\/code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-white-color\"><code>&lt;\/version&gt;<br>&lt;\/dependency&gt;<\/code><\/mark><\/p>\n\n\n\n<h6 class=\"wp-block-heading\"><a rel=\"noreferrer noopener\" href=\"https:\/\/search.maven.org\/artifact\/org.mariuszgromada.math\/MathParser.org-mXparser\/5.0.2\/jar\" target=\"_blank\">Maven &#8211; Gradle<\/a><\/h6>\n\n\n\n<p class=\"copy-cliboard has-background\" style=\"background-color:#404040\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-white-color\"><code>implementation <\/code><\/mark><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-yellow-color\">'org.mariuszgromada.math:MathParser.org-mXparser:6.1.0'<\/mark><\/strong><\/code><\/p>\n\n\n\n<h6 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/mariuszgromada\/MathParser.org-mXparser\/tree\/master\/CURRENT\/cpp\/lib\" target=\"_blank\" rel=\"noreferrer noopener\">CMake &#8211; Dependency \/ FetchContent (C++, MSVC, LLVM\/Clang, GNU\/GCC, MinGW, MSYS2, WSL, Windows, Linux, Unix, MacOS) <\/a><\/h6>\n\n\n\n<p class=\"copy-cliboard has-medium-font-size has-background\" style=\"background-color:#404040\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-white-color\"><code>include(FetchContent)<br>FetchContent_Declare(<br>   <\/code><\/mark><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-yellow-color\">MathParserOrgMxParser<\/mark><\/strong><\/code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-white-color\"><code><br>   GIT_REPOSITORY <\/code><\/mark><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-yellow-color\">https:\/\/github.com\/mariuszgromada\/MathParser.org-mXparser.git<\/mark><\/strong><\/code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-white-color\"><code><br>   GIT_TAG <\/code><\/mark><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-yellow-color\">v.6.1.0<\/mark><\/strong><\/code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-white-color\"><code><br>   SOURCE_SUBDIR CURRENT\/cpp\/lib<br>)<br>FetchContent_MakeAvailable(<\/code><\/mark><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-yellow-color\">MathParserOrgMxParser<\/mark><\/strong><\/code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-white-color\"><code>)<br>target_link_libraries(<strong>YourExecutable <\/strong><\/code><\/mark><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-yellow-color\">MathParserOrgMxParser<\/mark><\/strong><\/code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-white-color\"><code>)<\/code><\/mark><\/p>\n\n\n\n<h6 class=\"wp-block-heading\"><a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/mariuszgromada\/MathParser.org-mXparser\" target=\"_blank\">GitHub<\/a><\/h6>\n\n\n\n<p class=\"copy-cliboard has-background\" style=\"background-color:#404040\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-white-color\"><code>git clone <\/code><\/mark><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-yellow-color\">https:\/\/github.com\/mariuszgromada\/MathParser.org-mXparser<\/mark><\/strong><\/code><\/p>\n\n\n\n<h6 class=\"wp-block-heading\"><strong>OTHER DOWNLOAD OPTIONS<\/strong><\/h6>\n\n\n<p><a href='https:\/\/github.com\/mariuszgromada\/MathParser.org-mXparser\/releases\/download\/v.6.1.0\/MathParser.org-mXparser-v.6.1.0-dotnet-bin-only.zip' onclick='' class='wpi_designer_button   wpi_shadow wpi_shadow_ wpi_designer_button_preset_348 wpi_icon wpi_icon_download wpi_icon_left  ' target='' rel=''><i class=''><\/i><span class='wpi_text'>Download latest release \u2013 v.6.1.0 Sagitara: .NET bin only<\/span><\/a><a href='https:\/\/github.com\/mariuszgromada\/MathParser.org-mXparser\/releases\/download\/v.6.1.0\/MathParser.org-mXparser-v.6.1.0-jdk-bin-only.zip' onclick='' class='wpi_designer_button   wpi_shadow wpi_shadow_ wpi_designer_button_preset_348 wpi_icon wpi_icon_download wpi_icon_left  ' target='' rel=''><i class=''><\/i><span class='wpi_text'>Download latest release \u2013 v.6.1.0 Sagitara: JAVA bin only<\/span><\/a><a href='https:\/\/github.com\/mariuszgromada\/MathParser.org-mXparser\/releases\/download\/v.6.1.0\/MathParser.org-mXparser-v.6.1.0.zip' onclick='' class='wpi_designer_button   wpi_shadow wpi_shadow_ wpi_designer_button_preset_348 wpi_icon wpi_icon_download wpi_icon_left  ' target='' rel=''><i class=''><\/i><span class='wpi_text'>Download latest release \u2013 v.6.1.0 Sagitara: bin + doc<\/span><\/a><\/p>\n\n\n\n<h6 class=\"wp-block-heading\">NEWS FROM MATHPARSER.ORG<\/h6>\n\n\n\n<div class=\"AW-Form-2120798082\"><\/div>\n<script type=\"text\/javascript\">(function(d, s, id) {\n    var js, fjs = d.getElementsByTagName(s)[0];\n    if (d.getElementById(id)) return;\n    js = d.createElement(s); js.id = id;\n    js.src = \"\/\/forms.aweber.com\/form\/82\/2120798082.js\";\n    fjs.parentNode.insertBefore(js, fjs);\n    }(document, \"script\", \"aweber-wjs-b53aopyuz\"));\n<\/script>\n\n\n\n<h6 class=\"wp-block-heading\">SOURCE CODE<\/h6>\n\n\n\n<p class=\"has-text-align-center\"><a href='https:\/\/github.com\/mariuszgromada\/mXparser\/zipball\/master' onclick='' class='wpi_designer_button   wpi_shadow wpi_shadow_ wpi_designer_button_preset_799 wpi_icon wpi_icon_download wpi_icon_left  ' target='_blank' rel=''><i class=''><\/i><span class='wpi_text'>Source code .zip<\/span><\/a><a href='https:\/\/github.com\/mariuszgromada\/mXparser\/tarball\/master' onclick='' class='wpi_designer_button   wpi_shadow wpi_shadow_ wpi_designer_button_preset_799 wpi_icon wpi_icon_download wpi_icon_left  ' target='' rel=''><i class=''><\/i><span class='wpi_text'>Source code .tar.gz<\/span><\/a><br><a href='https:\/\/github.com\/mariuszgromada\/mXparser' onclick='' class='wpi_designer_button   wpi_shadow wpi_shadow_ wpi_designer_button_preset_799 wpi_icon wpi_icon_github wpi_icon_left  ' target='_blank' rel=''><i class=''><\/i><span class='wpi_text'>View on GitHub<\/span><\/a><a href='http:\/\/mathspace.pl\/tag\/mxparser\/' onclick='' class='wpi_designer_button   wpi_shadow wpi_shadow_ wpi_designer_button_preset_799 wpi_icon wpi_icon_external wpi_icon_left  ' target='_blank' rel=''><i class=''><\/i><span class='wpi_text'>MathSpace.pl<\/span><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">My other creative spaces<\/h2>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-spotify wp-block-embed-spotify wp-embed-aspect-21-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"Spotify Embed: Relearn\" style=\"border-radius: 12px\" width=\"100%\" height=\"352\" frameborder=\"0\" allowfullscreen allow=\"autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture\" loading=\"lazy\" src=\"https:\/\/open.spotify.com\/embed\/album\/3WIRgIVIFqtujgzULjOCt8?utm_source=oembed\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<h6 class=\"wp-block-heading\">DONATION<\/h6>\n\n\n<div class='wpi_slide wpi_slide_1266'><div class='wpi_slide_image'><\/div><div id='wpi_slide_content' ><div class='wpi_slide_heading'><div><span>Did you find the software useful?<\/span><\/div><\/div><div class='wpi_slide_text'>Please consider donation \ud83d\ude42<\/div><a href='https:\/\/www.paypal.com\/cgi-bin\/webscr?cmd=_s-xclick&#038;hosted_button_id=QJYYH86583LEN' onclick='' class='wpi_designer_button   wpi_shadow wpi_shadow_ wpi_designer_button_preset_748 wpi_icon wpi_icon_no wpi_icon_left  ' target='_blank' rel=''><i class=''><\/i><span class='wpi_text'>DONATE<\/span><\/a><\/div><div class='wpi_slide_footer' >Donation with PayPal<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":432,"menu_order":11,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"class_list":["post-470","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/mathparser.org\/wp-json\/wp\/v2\/pages\/470","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mathparser.org\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/mathparser.org\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/mathparser.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mathparser.org\/wp-json\/wp\/v2\/comments?post=470"}],"version-history":[{"count":8,"href":"https:\/\/mathparser.org\/wp-json\/wp\/v2\/pages\/470\/revisions"}],"predecessor-version":[{"id":22110,"href":"https:\/\/mathparser.org\/wp-json\/wp\/v2\/pages\/470\/revisions\/22110"}],"up":[{"embeddable":true,"href":"https:\/\/mathparser.org\/wp-json\/wp\/v2\/pages\/432"}],"wp:attachment":[{"href":"https:\/\/mathparser.org\/wp-json\/wp\/v2\/media?parent=470"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}