Missing logic and math operators #154
-
Hello, Now I started checking what the library itself provides in terms of ready-made operators and functions, and noticed that some 'basic' operators are not available.
Questions time :) I am also going to repeat myself: I really like the library as it is. I still prefer sticking with muParser rather than muParserX, due to the highlighted better runtime performance. I MAY consider in the future trimming some code inside the library for features I definately will not need, although such features are useful for a library with larger goals. Thanks for your attention Have a Nice Day :) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Some operators may not be available because everyone has a different preference or need. Binary operators are not supported because the underlying default type is a floating point value. Bitwise operators do not work on floating point values. muparser does not have a type system and cannot check wether a given equation makes sense. To be absolutely save one would need to introduce an int function and make sure binary operators can only be applied to the output of the int function. That looks odd in an equation. Alternatively one could implement the binary operator in a way that it simply converts the parameters to int. If you do this do not use (int) casting because your input may be something like "9.9999999999997". You dont want to truncate that to 9. Use a round function instead. In short its a can of worms i did not want to open in muparser because there is no satisfying solution. I put that solution into muparserx. However if anyone else wants to open that can of worms they would still need a different operator precedence so I added it. |
Beta Was this translation helpful? Give feedback.
-
Please feel free to keep asking questions, after all this is what this discussion forum is for. There is absolutely nothing wrong with that. I just cannot guarantee that I am able to reply in a timely manner or at all. But even if I cannot respond other people may be seeing your post and be able to respond. You figured out the limitations on your own and I agree that you can create a safe implementation if you add the apropriate checks. That is probably the best way to proceed. |
Beta Was this translation helpful? Give feedback.
Some operators may not be available because everyone has a different preference or need. Binary operators are not supported because the underlying default type is a floating point value. Bitwise operators do not work on floating point values.
muparser does not have a type system and cannot check wether a given equation makes sense. To be absolutely save one would need to introduce an int function and make sure binary operators can only be applied to the output of the int function. That looks odd in an equation. Alternatively one could implement the binary operator in a way that it simply converts the parameters to int. If you do this do not use (int) casting because your input may be some…