CalcPlus by VirxEC

What is ES6

Whenever ES6 is mentioned, Module JavaScript is what’s actually being talked about. If you don’t know what ModuleJS is, you can read about it here.

If you want to write in ES6, then just do this: <script type="module">/*ModuleJS here*/</script>. ES6 is currently unsupported in Internet Explorer (big surprise there) but it has been support for a while in Chrome, Edge, Firefox, Opera, and Safari.

About CalcPlus

This is a ES6 Library that let’s numbers be calculated up to 253-1 digits long, or 10(253-1)-1.

Please note that the ES6/Node version of this Library is extremely RAM efficient. The speed of your RAM may also limit the speed of the program, but the biggest bottleneck (for speed) is most often going to be your CPU. This is a change from built-in systems in programming languages, which hog tons of RAM but are very CPU efficient.

Average execution times in microseconds on a free repl.it account (@1.1 GHz with floats 12341234.12341234 and 56785678.56785678 and with powermode off):

  • add - 13
  • subtract - 13
  • isLessThan - 11
  • isLessThanEqual - 10
  • isGreaterThan - 10
  • isGreaterThanEqual - 14
  • round - 1
  • roundUp - 1
  • roundDown - 1
  • abs - 1
  • multiply - 217

It is planned that once the ES6 version is done, it will be ported to be a Python 3 Library.

Want to see this library in action? Just go here!

Advantages of using CalcPlus

Normally, you can only calculate numbers on a 64-bit OS as long as the final result is less than 18,446,744,073,709,551,616. (4,294,967,296 for a 32-bit OS.) Or, if your language supports using more RAM to calculate huge numbers without losing precision, (like Python,) then the max number is 10custom_max_integer-1.

In some modern languages, when you go over the limit it just starts to lose its precision. For example, to it, 18,446,744,073,709,551,621,573 is just 18,446,744,073,709,550,000,000. More and more languages these days are fixing this error, but there’s another really big error that they have yet to fix - float point errors (Why is this a problem/what is that?). CalcPlus gets rid of any and all floating-point errors, while also fixing the loss of precision in really big integers. On top of this, it’s really fast! (View the About CalcPlus section).

How does CalcPlus work

In short, it does basic function like addition & subtraction like a human would - breaking it down, solving it column by column:

      1 1   1
    3 0 2 . 0 1 5
+   0 1 8 . 9 9 0
=================
    3 2 1 . 0 0 5

And from there, multiplication is just repeated addition, dividing is just repeated subtraction, exponents are just repeated multiplication and that kind of thing. Of course, this is very inefficient, so there are a number of optimizations to vastly speed up the process. Weak computers can instantaneously calculate 2256, which is 115792089237316195423570985008687907853269984665640564039457584007913129639936. View the About CalcPlus section for more information on the speed of certain functions.

What languages does CalcPlus support

For now, it only supports ES6/NodeJS. I have plans to eventually port it to Python 3.

Installing/downloading CalcPlus

ES6 CalcPlus

<script type="module">
  import * as CalcPlus from "https://calcplus.virxcase.dev/calcplus.js";
  /*Import latest alpha*/
</script>

NodeJS CalcPlus

Some of you might already know everything, and some of you might not know about Node. For this purpose, I will be going through, step-by-step, everything from installing Node and NPM to configuring NPM to install from GitHub packages and importing CalcPlus into your project. If you know enough, you can just look further below for the import command.

  1. Download and install Node and the Node Package Manager (NPM) from nodejs.org.

  2. Create a project folder. For this project, I’ve gone to my coding folder called GitHub in Command Prompt and I ran mkdir ImportCalcPlus, which just creates a folder with said name. I then ran cd ImportCalcPlus so get into the directory. If you’re not already inside your OS’s command line, I would recommend doing that now and navigating to the folder. If you don’t know how to do that, look it up!

  3. Now, we must create our Node project. In your command line, run npm init. For now, just keep hitting your enter key until you come upon the prompt for a test command. Here, type node ./index.js. Again, keep hitting enter until you get to the end. You can fill out the rest of the details later! When asked “Is this OK?” just hit enter. A file called `package.json will be create in your directory.

  4. Open you project folder in you editor of choice. This could be anything from Notepad++ to Visual Studio Code. Don’t close out of you command line, yet.

  5. Go to package.json. Here, you’re going to add an extra line. Go to the end of the first line, and press your enter key and then your tab key. Here, put this line of JSON: "type": "module",

  6. Next, go to github.com and sign in. If you don’t have an account, you will need one for this!

  7. Go to github.com/settings/tokens and hit “Generate new token”. Then, enter your password.

  8. For the note, type NPM. Then, for the scopes, check off these:

    • write:packages
    • read:packages
    • delete:packages
  9. Scroll down and click “Generate token”. Copy the token and put it somewhere safe!

  10. Create a new file, and call it .gitignore. In this file, type *.npmrc. Even if you never intend to put you code up on GitHub, do this just incase! The file .npmrc will contain your token, and you don’t want this to get out on the internet!

  11. Create another new file, and call it .npmrc. In this file, type the following, replacing TOKEN with your personal token:

    //npm.pkg.github.com/:_authToken=TOKEN
    @virxec:registry=https://npm.pkg.github.com
    
  12. Go back to your command line. Here, type the following command. This will install CalcPlus!

    npm install @virxec/calcplus --save
    
  13. Finally, create a file called index.js. In this file, type the following:

    import * as CalcPlus from "@virxec/calcplus";
    

    Now, you can use all of the modules as reference in the CalcPlus wiki but with the CalcPlus. prefix. This uses ES6 modules, not Node modules, so you’re oing to want to look into those. You can then run npm test in your command line to run index.js.

Here’s the package.json file:

{
  "type": "module",
  "name": "importcalcplus",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "node ./index.js"
  },
  "author": "",
  "license": "",
  "dependencies": {
    "@virxec/calcplus": "^0.5.9"
  }
}

What’s the largest number CalcPlus can understand, written out

I can’t put it here. It’s WAY to big. If you want to get an idea of just how big it is, go to the one million digits of pi page and try to get to the bottom. Then multiply the length of that page by trillions of trillions of times. That’s why it can’t be here, it’s just a really damn big number.

Contact me

I’m in the EST time zone.

Discord: discord.gg/N3ppwGu

Email: [email protected]

Issues/Questions/Feature Requests: github.com/VirxEC/CalcPlus/issues