math-literal
v0.1.1
Published
Math Literal -----
Downloads
142
Readme
Math Literal
BigNumber.add(BigNumber.div(BigNumber.plus(a, BigNumber.times(b, c)), d), e)
Or
math`(${a} + ${b} * ${c}) / ${d} + ${e}`
I like the second one. ^^
there is also mathIs
that returns a boolean
mathIs`abs(${a}) > ${b}`
Available Operators
Arithmetic Operators
+
: Addition-
: Subtraction*
orx
: Multiplication/
: Division**
or^
: Exponentiation
Special Arithmetic Operators
<<
: Left move decimals (equivalent to multiplying by a power of 10)>>
: Right move decimals (equivalent to dividing by a power of 10)
Unary Operators
-
: Negation (when used before a number or expression)
Functions
round(x)
: Round to the nearest integerfloor(x)
: Round down to the nearest integerceil(x)
: Round up to the nearest integersqrt(x)
: Square rootabs(x)
: Absolute valueln(x)
: Natural logarithmexp(x)
: Exponential function (e^x)max(x, y)
: Maximum of two valuesmin(x, y)
: Minimum of two values
Comparison Operators (for mathIs
)
>
: Greater than>=
: Greater than or equal to<
: Less than<=
: Less than or equal to===
or==
: Equal to!==
or!=
: Not equal to
Logical Operators (for mathIs
)
&&
: Logical AND||
: Logical OR
Grouping
( )
: Parentheses for grouping expressions and function arguments
Note: The order of operations follows standard mathematical conventions, with functions and parentheses having the highest precedence, followed by exponents, multiplication/division, and then addition/subtraction.