A Node.js web application that is used to convert decimal inputs to IEEE754-2008 binary format. Representations are shown in both binary and hexadecimal. Options to round (round to nearest evens, truncation, ceiling, floor, and arithmetic rounding) are provided for numbers with more than 16 digits.
Ensure first that node.js
and npm
are both installed in your system. From there, open the folder containing the project in the command line.
Execute the following snippets of code in succession to initialize the node.js
project:
npm init -y
then
npm install express decimal.js --save
Following that, type in node index
into the command line. The project would now be open on localhost:3001
.
An option is provided for results to be saved in an external text file output.txt
; this would be located in the project folder. Previous saved results would not be overwritten.
Problems were initially encountered with Javascript's limited ability to represent beyond numbers with a factor of 10^308. This led to the use of an external library decimal.js
, to aid in representing
the numbers in memory. Use of Flask and Python was considered; however, the steep learning curve and negligible gains lead to the abandonment of the idea. Issues were also faced when trying to output values
into a .txt file from the web application. Nevertheless, a module within node.js was found (fs
); it aided in accomplishing the task.
Input: 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
(Infinity Exponent)
Input: -10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (Negative Infinity Exponent)
Input: 9999999999999999000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (Maximum Magnitude)
Input: 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 (Minimum Magnitude)
Input: -9999999999999999000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (Negative Max Magnitude)
Input: -0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 (Negative Min Magnitude)
Input: 0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 (Below Min Mag)
Input: -0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 (Neg Below Min Mag)
Rounding Cases: Input: 3.1415926535897955 (Gaussian Rounding)
Input: 3.1415926535897955 (Truncation)
Input: 3.1415926535897955 (Floor)
Input: 3.1415926535897955 (Ceiling)
Input: 3.1415926535897955 (Arithmetic Rounding)
Input: -3.1415926535897955 (Gaussian Rounding)
Input: -3.1415926535897955 (Truncation)
Input: -3.1415926535897955 (Floor)
Input: -3.1415926535897955 (Ceiling)
Input: -3.1415926535897955 (Arithmetic Rounding)
This simulation project is made in partial fulfillment for the requirements of a degree in Computer Science.
Two open source projects were used to aid in making this application: decimal.js
, for representing large numbers that vanilla Javascript could not, and express
for routing.