Git Product home page Git Product logo

math.ts's Introduction

@jdeurt/math.ts

Utility types for numbers.

Installation

npm install @jdeurt/math.ts

API

Number types passed to any of the following utility types are casted to integers. For example, Add<5, 3.5> will return 8.

int A, int B => Add A B -> int

Adds integers A and B and returns the result.

type Result = Add<5, 3>; // 8

int A, int B => Sub A B -> int

Subtracts integer B from A and returns the result.

type Result = Sub<5, 3>; // 2

int A, int B => Mul A B -> int

Multiplies integers A and B and returns the result.

type Result = Mul<5, 3>; // 15

int A, int B => Div A B -> int

Divides integer A by integer B and returns the result.

type Result = Div<10, 2>; // 5

int A, int B => Mod A B -> int

Finds the modulus of integer A by B and returns the result.

type Result = Mod<10, 3>; // 1

int A, int B => Pow A B -> int

Raises integer A to the power of B and returns the result.

type Result = Pow<2, 3>; // 8

int A, int B => Eq A B -> int

Checks if integer A is equal to B and returns 1 if true, otherwise 0.

type Result = Eq<5, 5>; // 1

int A, int B => Gt A B -> int

Checks if integer A is greater than B and returns 1 if true, otherwise 0.

type Result = Gt<5, 3>; // 1

int A, int B => Lt A B -> int

Checks if integer A is less than B and returns 1 if true, otherwise 0.

type Result = Lt<5, 7>; // 1

int A, int B => Gte A B -> int

Checks if integer A is greater than or equal to B and returns 1 if true, otherwise 0.

type Result = Gte<5, 5>; // 1

int A, int B => Lte A B -> int

Checks if integer A is less than or equal to B and returns 1 if true, otherwise 0.

type Result = Lte<5, 7>; // 1

License

MIT © Juan de Urtubey

math.ts's People

Contributors

jdeurt avatar

Stargazers

Jacob Bogers avatar

Watchers

 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.