• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Library] matheval
#1
matheval



[Image: matheval.svg?branch=master] [Image: matheval.svg] [Image: matheval.svg] [Image: matheval.svg]



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 :




PHP Code:
#include<matheval>

main(){

? ?
printf("(1)^(32/3)-1 = %f",MathEval("(1)^(32/3)-1"));





Testing



To run the tests:



sampctl package run



Dependencies



Repository

https://github.com/Sreyas-Sreelal/matheval
  Reply
#2
good job
  Reply


Forum Jump: