Skip to content

Calculate sums and averages using both the CPU and FPU for integer and floating-point numbers

Notifications You must be signed in to change notification settings

flwrr/Sum-and-Average-Calculator

Repository files navigation

Sum and Average Calculator

As an exercise to explore the differences between integer and floating-point arithmetic in assembly, this program calculates the sums and averages of 10 imput integers using the CPU and 10 input floating-point numbers using the FPU. For both, the program first converts user input from strings to numbers while validating input, then calculates their sum and average, finally displaying formatted results for 10 input values.

🔶 Run Example - Integers

This portion of the program is fairly straightforward and is capable of processing the full range of 32-bit signed integers from -2,147,483,648 to 2,147,483,647. The most challenging aspect was parsing + and - signs from input, and the logic of deciding when to and when not to display them to the user (e.g., not -0 nor +0).

Calc_Integers-crop

🐟 Run Example - Floating Point Numbers

Using the FPU, this portion of the program accepts signed inputs with up to 5 decimal places. A very memorable lesson on floating-point arithmetic and floating-point errors. Working with the FPU and fixing rounding errors without looking much up was a challenging exercise.

Calc_FloatingPoint

About

Calculate sums and averages using both the CPU and FPU for integer and floating-point numbers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published