#112470 - 2004-01-26 03:01 PM
Re: Enhanced Math - power on n
|
Richard H.
Administrator
![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif)
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
This will handle fractional and negative base numbers and negative exponents. It will not handle fractional exponents, but it does handle n^0 :
Code:
Function Pwr($i,Optional $p)
If Not $p $p=2 EndIf
If $p<0
$p=0-$p
$i=1.0/$i
EndIf
$Pwr=1.0
While $p
$Pwr=$Pwr*$i
$p=$p-1
Loop
EndFunction
|
Top
|
|
|
|
#112471 - 2004-01-26 06:02 PM
Re: Enhanced Math - power of n
|
NTDOC
Administrator
![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif)
Registered: 2000-07-28
Posts: 11624
Loc: CA
|
Thanks gentlemen but I'm also looking for it to support the fractional exponent. I'm looking to implement a form that will require this type of math.
|
Top
|
|
|
|
#112474 - 2004-01-26 06:43 PM
Re: Enhanced Math - power of n
|
NTDOC
Administrator
![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif)
Registered: 2000-07-28
Posts: 11624
Loc: CA
|
Shawn,
How is that going to work now? Looks like you may have some new good stuff coming, but also harder now to track what code is KiXtart code and what code is KiXforms code.
Well since I'm not a math junkie myself I don't forsee myself needed a LOT of additional math support. For now I'm looking to add some code that requires something like 2^0.xx or 2^x.xx or similar.
Edited by NTDOC (2004-01-26 06:45 PM)
|
Top
|
|
|
|
#112475 - 2004-01-26 06:44 PM
Re: Enhanced Math - power of n
|
Shawn
Administrator
![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif)
Registered: 1999-08-13
Posts: 8611
|
Right now there is COS() SIN() and PI, if there is anything else Kix-worthy, just let me know...
The next release of KF is done. Me and Stevie B are "syncing-up" the releases of KiXforms and KiXforms Designer ... just working on some last minute details ...
-Shawn
btw - I just added a new thingy lastnight ... it retrieves the commandline that was used to kix-off the script, the result is like this:
E:\>kix32 test.kix /r /y
[test.kix]
?"cmdLine = " + $System.Environment.CommandLine
[eof]
produces this:
cmdLine = kix32 t /r /y
funny thing is, no we got it - it isn't as "great" as one would suppose. if you try something like this:
E:\> kix32 test.kix /y shawn.txt
kix tries to open shawn.txt as a kixscript lol
-Shawn
Edited by Shawn (2004-01-26 06:50 PM)
|
Top
|
|
|
|
#112479 - 2004-01-26 07:00 PM
Re: Enhanced Math - power of n
|
Shawn
Administrator
![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif)
Registered: 1999-08-13
Posts: 8611
|
The math library is dead simple to use, even standalone:
Code:
; Root namespace
$System = CreateObject("Kixtart.System")
; Math object
$Math = $System.Math()
; Stuff ...
?"Cos=" $Math.Cos(0.5)
?"Sin=" $Math.Sin(0.5)
yields:
Quote:
Cos=0.877582561890373
Sin=0.479425538604203
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 132 anonymous users online.
|
|
|