FastCalc
FastCalc Result# = Expression
 
Parameters:

    Result# = Expression
Returns: NONE
 

      FastCalc is a special case command that allows you to by pass the expression resolve and directly feed a list of simple math operations into a cut down math engine.

      Unlike a normal expressions, FastCalc operations are perform linearly across the expression, from LEFT to RIGHT. No precedence is considered. Brackets are not supported, and the result is returned in the variable defined to accept it.

      Since FastCalc is a special case, it can only perform operation upon floating point variables. You can NOT use literal constants within the expression.



FACTS:


      * FastCalc expressions can perform basic math operations such as +, -, /, * and assignments (=) and powers (^).

      * FastCalc expressions may include the following math functions Cos(),Sin(),Tan(),RND(),Sqrt(). FastCalc expression can not start with a function though.

      * FastCalc expressions can only operate upon floating point variables. Nothing else.

      * Speed Wise FastCalc is only normally only faster with expressions with at least 3 operations in them.

      * FastCalc has absolutely NO error trapping ! USE AT YOUR OWN RISK !





Mini Tutorial:


      The following is just some mock up examples to show how you could rearrange normal expressions for use with FastCalc


  
  
; Init some variables to perform some calculations with
  a#=10
  b#=20
  c#=30
  d#=40
  
  
  
; ===============
;  Example #1
; ===============
  
; A normal  expression
  Result#= A# +b#+C#
  
; The same expression rearranged for FastCalc
  FastCalc FastCalcResult#=A# +b#+C#
  
  Print Result#
  Print FastCalcResult#
  
  
  
; ===============
;  Example #2
; ===============
  
; A normal  expression
  
  Result#= A# +b#*10
  
; The same expression rearranged for FastCalc
  Temp#=10
  FastCalc FastCalcResult#=b#*temp#+a#
  
  Print Result#
  Print FastCalcResult#
  
  
  
; ===============
;  Example #3
; ===============
  
; A normal  expression
  Result#= Cos(a#) * c#
  
; The same expression rearranged for FastCalc
  FastCalc FastCalcResult#=C# * Cos(a#)
  
;   Note  Operations like COS/SIN etc can't be the
;   first operation in the FastCalc list
  
  Print Result#
  Print FastCalcResult#
  
  
; ===============
; Example #4
; ===============
  
; A normal  expression
  Result#= (B#*C#) +(b#+D#)
; The same expression rearranged for FastCalc
  FastCalc FastCalcResult#= b# *C#=temp#, B#+D#+Temp#
  
  Print Result#
  Print FastCalcResult#
  
  
; refresh the screen wait for a key press
  Sync
  WaitKey
  




This example would output.

  
  60.0
  60.0
  210.0
  210.0
  29.5442
  29.5442
  660.0
  660.0
  

 
Related Info: Cos | Float | Literals | Sin | Sqrt | Tan :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com