# Ultimate CS Calculator

https://calc.bornais.ca Made by Jeremie Bornais jeremiejbornais@gmail.com jere_mie#9432

## Inspiration

As a Computer Science student, I find myself performing the same menial calculations often in my classes. Moreover, even after completing these calculations manually, I still have no convenient of checking my work to make sure it's right. Existing sites are often only for one purpose, and aren't mobile optimized. That's why I created the Ultimate CS Calculator, a JavaScript-based, mobile-responsive web app that serves as a one-stop shop for CS students.

## What it does

#### There are five main components to the Ultimate CS Calculator

• This allows the user to convert floating-point numbers from any two different-based number systems (ex. binary to hexadecimal)
• 1's Compliment / 2's Compliment Converter
• This calculates the 1's compliment and 2's compliment of a user-inputted binary number
• This calculator allows the user to perform simple or complex calculations on numbers from base 2-36.
• It supports the following:
• Exponents and Square Roots
• Brackets
• Trigonometric Functions (Base 10 and Below)
• Conversions (ex. cm to inches)
• Imaginary/Complex Numbers (ex. sqrt(-1))
• Matrix Multiplier
• This allows the user to input 2 matrices and calculate the product matrix of the two
• Matrix Info
• This allows the user to calculate various properties/manipulations of a given matrix, including:
• The inverse of the matrix
• The transposed matrix
• The determinant of the matrix
• The trace of the matrix
• The eigenvalues of the matrix
• The eigenvectors of the matrix

## How I built it

This web app was made entirely in JavaScript, in an effort to keep all the calculations client-side, so as to save server resources. I used the math.js library for parsing and evaluating expressions and matrices. However, I manually wrote functions to convert and sanitize user input for non-decimal numbers, to allow for radix conversions, as well as using different bases in the calculator. This was all written in vanilla JS. The look and feel of the web app comes from Bootstrap, custom CSS, and CSS Grid (in conjunction with HTML) Hosting is done on GitHub Pages, and the app can be found at https://calc.bornais.ca

## Challenges I ran into

The biggest challenge I ran into was with sanitizing user input for math.js. Before the expression is parsed and evaluated, my functions manually iterate through the expression and convert non-decimal numbers into decimal before evaluating. This posed several issues, namely with floating point numbers, as well as JavaScript's "Duck Typing". This made it difficult to sanitize the input, and also caused errors in some of the matrix calculations. However, these challenges were conquered, and the app is now fully-functioning.

## Accomplishments that I'm proud of

I'm proud of my ability to overcome some of the errors I was having, namely with getting the calculator to correctly parse 11+ based expressions and negatives. I'm also proud of the ability to offer such a complete bundle of resources for CS and Math Students. I know I would have loved to have this when I first started University.

## What I learned

I learned a lot about JavaScript by doing this project. I haven't worked with it much before, but this time I was able to use a third party library in conjunction with a lot of hand-written functions to provide a complete user experience. This was also my first time using CSS Grid, which I found to be incredibly useful. I definitely plan on using it in more projects in the future.

## What's next for Ultimate CS Student Calculator

I'm open to feedback! I hope to get feedback from my fellow students as well as other hackers about what they would like to see, or what they would have liked to have when they were studying a particular subject. JS and math.js are both very powerful, and I believe that there is still much more to offer the student community!

I will continue to add new features to this app as I find new ones that people would find useful.