[Include] matheval.inc
#1

matheval

This is a simple library for evaluating mathematical expressions given as string literals.Currently supported operators are:
  • + - addition
  • - - subtraction
  • ^ - exponential
  • / - division
  • * - product
If you have any issues or improvements to be made in this code just open an issue or pull request

Installation

If you are using sampctl just use

sampctl package install Sreyas-Sreelal/matheval

Otherwise just clone the repository

git clone https://www.github.com/sreyas-sreelal/matheval.git

and add matheval.inc to your pawno/includes folder

Usage

There is only one function

MathEval(expression[])

parameters
  • expression[] - mathmatical expression in string literal
returns
  • NaN if failed
  • if success,value in floating point

For example :


Код:
#include<matheval>
main(){
    printf("(1+3)^(32/3)-1 = %f",MathEval("(1+3)^(32/3)-1"));
}
Testing

To run the tests:

sampctl package run

Dependencies
Repository
https://github.com/Sreyas-Sreelal/matheval
Reply


Messages In This Thread
matheval.inc - by SyS - 22.08.2018, 14:53
Re: matheval.inc - by J0sh... - 22.08.2018, 15:08
Re: matheval.inc - by coool - 22.08.2018, 15:14
Re: matheval.inc - by Hunud - 22.08.2018, 15:43
Re: matheval.inc - by SyS - 22.08.2018, 15:54
Re: matheval.inc - by Marshall32 - 24.08.2018, 07:36
Re: matheval.inc - by BigETI - 24.08.2018, 09:04
Re: matheval.inc - by GhostHacker9 - 31.08.2018, 03:38

Forum Jump:


Users browsing this thread: 2 Guest(s)