Skip to content

HeryMantilla/LexMath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LexMath LexMath 1.0

IMPORTANT NOTE: First and last Release.

By DreamVB
Converted to PHP by HACKPRO TM (C) 2008-2009
Versión: 1.0
All rights reserved


@author Heriberto Mantilla Santamaría
@version 1.0

Operators & Functions

Single Operators

Description Operator Uses

Addition

+

Expr + Expr

Subtraction

-

Expr - Expr

Multiplication

*

Expr * Expr

Division

/

Expr / Expr

Modulus

%

Expr % Expr

Parenthesis

()

(Expr)

Unary +

+

+(Expr)

Unary -

-

-(Expr)

Assign

=

Var = expr

Equals

=

Expr = Expr

Bitwise AND

&&

Expr && Expr

Bitwise OR

||

Expr || Expr

Keywords operators

Description Operator Uses

Bitwise AND

AND

Expr AND Expr

Bitwise OR

OR

Expr OR Expr

Bitwise XOR

XOR

Expr XOR Expr

Shift Left

SHL

Expr SHL Expr

Shift Right

SHR

Expr SHR Expr

Integer Division

DIV

Expr DIV Expr

Bitwise Not

NOT

Not Expr

Modulus

MOD

Expr MOD Expr

Bit Shifting

Description Operator Uses

Shift Left

<< 

Expr << Expr

Shift Right

>> 

Expr >> Expr

Some Inbuilt Functions

ABS

expr

ATN

expr

COS

expr

EXP

expr

LOG

expr

RND

expr

ROUND

expr

SGN

expr

SIN

expr

SQR

expr

TAN

expr

SUM

exprList Separated with a comma.

IFF

Truepart, Falsepart, Expression.

Built in variables

PI = 3.1415926535897931
E  = 2.71828182845905

Examples

require_once('./lexmath.php');

$lex = new LexMath();

echo $lex->Calc('2 + 2 * (5 + 5)', true);
echo $lex->Calc('8+1/7*4+(9*4+1*(2+8))*6', true);
echo $lex->Calc('15 MOD 2', true);
echo $lex->Calc('2 ^ 2', true);
echo $lex->Calc('15 % 2', true);
echo $lex->Calc('(-5 + 3)', true);
echo $lex->Calc('(-5 + 3) / -5 * (-2.5) + 6', true);
echo $lex->Calc('PI', true);
echo $lex->Calc('E', true);