PB.Ex Math (Windows)

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

PB.Ex Math (Windows)

Post by RSBasic »

Hello

With this library it is possible to write arithmetic operations and paths in a string and have them calculated by the library. All basic arithmetic operations and other operations are supported.

Functions:
  • Calculate()
    • Syntax:

      Code: Select all

      Result = Calculate(Calculation$, @ErrorOutput$)
    • Description: Calculates the given mathematical task.
    • Parameter:
      1. Calculation$: The following operations can be used: + - ± * / % ^ e == != > >= < <= ! && || pi sqrt() abs() round() min() max() ceil() floor() trunc() log() log10() cos() sin() tan() acos() asin() atan() cosh() sinh() tanh() deg2rad() rad2deg() rand()
      2. @ErrorOutput$: If an error occurs, the error message is stored in the string variable.
    • Return value: The result is returned as a double value.
    • Example:

      Code: Select all

      EnableExplicit
      
      Global PBEx_Math
      
      CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
        PBEx_Math = OpenLibrary(#PB_Any, "PB.Ex_Math_x86.dll")
      CompilerElseIf #PB_Compiler_Processor = #PB_Processor_x64
        PBEx_Math = OpenLibrary(#PB_Any, "PB.Ex_Math_x64.dll")
      CompilerEndIf
      
      If PBEx_Math
        Prototype.d Calculate(Calculation.p-Unicode, ErrorOutput)
        Global Calculate.Calculate = GetFunction(PBEx_Math, "Calculate")
        
      EndIf
      
      Define ErrorOutput$ = ""
      
      Debug "1 + 2 - 1 = " + Calculate("1 + 2 - 1", @ErrorOutput$)
      Debug "2^32 = " + Calculate("2^32", @ErrorOutput$)
      Debug "5 + 2 * 2 = " + Calculate("5 + 2 * 2", @ErrorOutput$)
      Debug "(10 + 20) * 10 = " + Calculate("(10 + 20) * 10", @ErrorOutput$)
      Debug "pi * 4 = " + Calculate("pi * 4", @ErrorOutput$)
      Debug "2.5 + 10 = " + Calculate("2.5 + 10", @ErrorOutput$)
      Debug "Modulo = " + Calculate("2 % 1 == 0", @ErrorOutput$)
      Debug "AND condition = " + Calculate("1 == 1", @ErrorOutput$)
      Debug "sqrt(64) = " + Calculate("sqrt(64)", @ErrorOutput$)
      Debug "round(5.4) = " + Calculate("round(5.4)", @ErrorOutput$)
      Debug "is 5 ot 10 greater? = " + Calculate("max(5, 10)", @ErrorOutput$)
      Debug "15 > 10? = " + Calculate("15 > 10", @ErrorOutput$)
      Debug "sin(1.5708) = " + Calculate("sin(1.5708)", @ErrorOutput$)
      
      CloseLibrary(PBEx_Math)
      
If you want to have some additional functions besides this one, which do not exist in PB, just suggest them.

Systemvoraussetzungen:
  • Windows Vista oder höher
  • .NET Framework 4.5 oder höher
  • Unicode-Aktivierung (standardmäßig ab PB 5.50)
Licence: This DLL file is free of charge and may be used both privately and commercially.
The following copyright texts must be provided:
Copyright(c) 2017 François Ségaud
Copyright © 2019 RSBasic.de
Download: This project was discontinued due to errors and is no longer available.

I would be very pleased about feedbacks, improvement suggestions, error messages or wishes. If you want to support me, you can also donate something. Thanks :)
Image
Image
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: PB.Ex Math (Windows)

Post by RSBasic »

PB.Ex Math 1.0.1.0 has been released.

Changelog:
  • Changed: Calculate(): There is no longer case sensitivity.
  • Bugfix: Calculate(): If an error occurred, then other calls also failed.
Image
Image
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: PB.Ex Math (Windows)

Post by RSBasic »

PB.Ex Math 1.0.2.0 has been released.

Changelog:
  • Changed: Calculate(): Negating with the minus sign is now possible.
Image
Image
User avatar
pf shadoko
Enthusiast
Enthusiast
Posts: 291
Joined: Thu Jul 09, 2015 9:07 am

Re: PB.Ex Math (Windows)

Post by pf shadoko »

very useful
It should be integrated into PB.
thank you
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: PB.Ex Math (Windows)

Post by Little John »

If someone wants cross-platform PureBasic source code (strictly tested), see e.g. here:
Evaluate and process math expressions
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Re: PB.Ex Math (Windows)

Post by djes »

Great, thank you for sharing !
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: PB.Ex Math (Windows)

Post by RSBasic »

I recommend the code by Little John. This project is discontinued.
Image
Image
Post Reply