Hi there,
I'm not a maths newb so don't try flaming me, please (i am doing FMaths)
Anyway, I'm coding an expression parsing and it's going pretty sweetly. It includes all the basic binary functions such as * / + - ^, has support for brackets, allowing you to overwrite the basic BODMAS/PEDMAS order. I also have basic unary functions such as % (modulus/absolute) and factorial (!).
The problem I have is deciding on the
'precedence' of these unary elements and also their
'associativity'.
I'm thinking to assign the same precedence as multiplication for factorial (!) as that is basically a short hand way of writing n*n1*n2 etc. Also to let it be RTL associative as thats how its done, but i'm not sure.
[edit]on the topic of factorials, are negative! = 0?[/edit]
Modulus, should that not be the most prioritised? as %(1+2*4) would be %12 ? Is this one too LTR associative?
[edit2]Also as a side point what about functions? as to what precedence should they be given? Sin, Cos and Tan, for example, highest priority?[/edit2]
Thanks,
any help is greatly appreciated,
regards,
rich