Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.
/ calc Public archive

Simple mathematical expression solver that supports operator priorities.

Notifications You must be signed in to change notification settings

xfnty/calc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Calculator in C++

preview.gif

Much simpler python version (140 loc)

Features

  • REPL
  • Floating-point numbers
  • Mathematical constants: Pi, e
  • Operators: +, -, *, /, ^, %, !
  • Grouping expressions: (...), |...|

Building and Running

  • Configure, build and run (after cloning the repo): make
  • Configure CMake: make c
  • Build the project: make b, make build
  • Build and run: make args="'-2 * 2 + 1.5!'"
  • Run: make r ...
  • Run using gdb: make d args="'1+5!'"

make configure build_type=Release will disable debug messages.

Credits & References

TODO

  • Parser error messages
  • Make macros in Util.h an inline functions
  • Better stack-related error handling
  • Remove else blocks at the end of functions in ExpressionEvaluator
  • Fix ^ operator and increase its precedence
  • Better std::string usage
  • Builtin functions: sin(), ctan(), ln(), floor(), ceil() ...
  • Fix Windows build

About

Simple mathematical expression solver that supports operator priorities.

Topics

Resources

Stars

Watchers

Forks