Skip to content

lmarchesoti/cpp_shell_calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cpp_shell_calculator

Interactive Shell Calculator in C++ using Boost Libraries

Features

Integer, float and double precisions by the -(i/f/d) command.

+, -, * and / operations along with parentheses. add, sub, mul and div aliases can also be used.

[M#] command to insert result into memory position #. Will create a new one in sequence if the number is too large.

clear M# to clear # memory position

clear command

exit command

Libraries

This calculator uses the c++ boost libraries. More specifically:

boost/xpressive to parse the command line through regex

boost/lexical_cast for safer type casts ;)

Compilation

fill BOOST_DIR in the makefile with the directory of your boost libraries, then just run:

make

Description

main.cpp accepts a parameter telling the initial precision to use(defaults to float). It then instantiates the calculator of the Calculator type.

Calculator.h is the header file for the Calculator class.

Calculator.cpp is the main file for the calculator. It parses the aforementioned commands. Every time an expression is entered, it is converted to postfix via a simplified Shunting Yard algorithm(because it doesn't have all operations and functions) and put on a stack. It is then evaluated and set to the accumulator register(memory position 0).

About

Interactive Shell Calculator in C++. Features command line configuration for precision type (integer/float/double) implemented with templates, expression parsing with operator precedence, and memory. Uses BOOST/xpressive to parse input as regular expressions and converts expressions from infix to postfix using a modified Shunting Yard algorithm.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors