I've made a fraction-based calculator, for simplifying rational expressions (written in ANSI-C using vi)
I was aiming to merge a scientific calculator with "bc", because I often need to simplify various fractions and whatnot. Quite happy with the result!
Uses shunting yard algorithm to evaluate the expressions, and a naive descent parser (I think?) to tokenise
Aside: OpenBSD's "editline" is very easy to use
Please ask any questions 😀
This entry was edited (1 week ago)
Devine Lu Linvega
in reply to Pat • • •That's such a nice idea, I went through the same motion for my own calculator, there's some interesting operators you can do with this, like to swap the numerator and denumerator, or break them back into their individual digits:
I've named the reverse of a division, vidision.
Pat
in reply to Devine Lu Linvega • • •@neauoire Ooh that is very cool, it really shows off how great stacks are as a construct. Its quite fun that a good way of performing infix maths is just to convert it to RPN
Mixed-fractions, decimal/fraction conversion, and some misc functions are on the TODO list in my head. I probably also need to add variables, as currently the result is just printed out?
I actually just treat everything as a fraction, so there's not really a concept of separate digits. Its all just reciprocals
Devine Lu Linvega
in reply to Pat • • •