Git Product home page Git Product logo

mathlibrary.cmd's Introduction

MathLibrary.cmd

A collection of math subroutines written in Windows batch script. Includes floating point and large number support.

MathLibrary.cmd was originally written to make it somewhat possible to solve Project Euler (https://projecteuler.net/) problems using Windows batch script (CMD) - this necessitated working floating point and large number support, neither of which is provided natively by Windows batch script. Usual workarounds in production environments for this issue involve piping output from other scripting languages, such as VBScript or PowerShell, into CMD, or just not solving complex math problems in a Windows batch script; both of these solutions are perfectly valid and reasonable.

MathLibrary.cmd is not a reasonable solution to these problems and should not be used in production by anyone. However, if you ever woke up and asked yourself, "Is it possible to get CMD to do floating point math on arbitrarily large numbers without leaving the CMD environment?", this project should answer that question in the affirmative.

###HOW TO USE There are two scripts in this repo:

  • MathLibrary.cmd
    • This is the script that does all the math. To use it, type in the equation like so: MathLibrary.cmd 1 + 2. At the present time, it can also handle subtraction (MathLibrary.cmd 2 - 1), multiplication (MathLibrary.cmd 2 * 1), division (MathLibrary.cmd 2 / 1), and comparison (MathLibrary.cmd 2 com 1).
  • UnitTest.cmd
    • This is the script used to test MathLibrary.cmd's performance and accuracy. You can test individual functions by including the arithmetic symbol as an argument - for example, UnitTest.cmd + will run addition tests. If you supply no argument, it'll run all tests.

###VERSION HISTORY

  • 0.3
    • This is the first release in which division is actually usable.
      • :ExtDivision no longer calls :ExtMultiply - instead, Divisor * (1-10) is handled by incrementing itself via :ExtAdd.
      • Removed extraneous calls to :ExtDim.
  • 0.2
    • Significant performance improvements (up to 50%) for all arithmetic functions by removing repeated calls to :ExtDim and instead tracking length and decimal position arithmetically.
  • 0.1
    • Added negative number support to all functions.
  • 0.0 (Initial Sync)
    • Addition, subtraction, multiplication and division of positive arbitrarily large floating point numbers.
    • Does the math like an elementary school student - slowly and column by column via string manipulation.

###TODO

  • Finish UnitTest.cmd to facilitate easier troubleshooting.
  • Use CMD's built-in math abilities more efficiently. Namely...
    • Explore rewriting ExtAdd and ExtSubtract to use 8-digit blocks, instead of performing math column by column.
    • Rewrite ExtMultiply to use 4-digit blocks, instead of performing multiplication column by column.

###FURTHER DETAILS For additional details, follow my blog, especially the posts tagged MathLibrary.cmd.

mathlibrary.cmd's People

Contributors

oatworm avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.