You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to implement a percentage calculation in form of:
20 + 19% that should result in 23.8 or
45 * 10% that should result in 202.5
For the first one you could also state 20 * 1.19, but the users are more familiar to the first way.
As I can see, the calculator can be extended, but operators always follow the form x [operator] y.
Do you see a way how I can implement this with the AbstractSymbol API?
Greetings from Germany
Volker
The text was updated successfully, but these errors were encountered:
I try to implement a percentage calculation in form of: 20 + 19% that should result in 23.8
well, good luck. 😉
20 + 19% is the same as (20 + 19%) wich is the same as (20 * 1.19)
Okay, let's ignore the brackets for know, so we assume 20 + 19% is exactly the same as 20 * 1.19.
So we could say that the + operator is transformed into *.
Unfortunately, in the current implementation operators always operate on numbers.
How could the plus operator (class) decide when it has to do a conventional addition and when to do a multiplication instead? Right know I do not have an answer.
But this is just straight forward thinking, maybe there are other ways.
45 * 10% that should result in 202.5
I guess that should be possible when allowing unary operators to be in postfix notation.
I need some time to figure out how to do that (haven't spent much time with StringCalc lately).
Hy Chris,
I try to implement a percentage calculation in form of:
20 + 19% that should result in 23.8 or
45 * 10% that should result in 202.5
For the first one you could also state 20 * 1.19, but the users are more familiar to the first way.
As I can see, the calculator can be extended, but operators always follow the form x [operator] y.
Do you see a way how I can implement this with the AbstractSymbol API?
Greetings from Germany
Volker
The text was updated successfully, but these errors were encountered: