I wrote a simple math plotter in C # using the free Patrick Lundin's Math parser.
Now my code snippet:
for (float value = -xaxis; value < xaxis; value += konst) { hash.Add("x", value.ToString()); double result = 0; result = parser.Parse(func, hash);...
This works great for functions defined on real numbers. But, when I want to analyze functions defined only on R +, for example, ln (x), the natural parser gives NaN the result.
Now I tried to handle it using exception handling, for example:
for (float value = -xaxis; value < xaxis; value += konst) { hash.Add("x", value.ToString()); double result = 0; try{ result = parser.Parse(func, hash); } catch { count = false;
But this does not work, while debugging, catch is not executed at all.
Please, what am I doing wrong? Thanks.
source share