EXP()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

EXP()

Post by chris319 »

Please include Exp() in PureBasic. Thanks again to El_Choni for this example:

Code: Select all

#E = 2.71828182

Procedure.f Exp(value.f)
  ProcedureReturn Pow(#E, value)
EndProcedure
Lebostein
Addict
Addict
Posts: 826
Joined: Fri Jun 11, 2004 7:07 am

Post by Lebostein »

And please, please, please add follow functions

- Abs() for integers, best way two functions: Abs() & AbsF()
- Sign()

And this after 5 years PureBasic!! :? This functions are basic BASIC-functions!
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Post by chris319 »

- Abs() for integers, best way two functions: Abs() & AbsF()
IMO there should be just one Abs() which can (or the compiler can) determine whether it is a float or integer.

As for other requests, we should be able to use a variable after Step in a For...Next loop. Requiring the use of a constant is ridiculous. And preferably not StepW and StepF, just Step.

Also requesting FP(). This is part of the ANSI/ISO standard for BASIC (yes, there IS a standard for BASIC). FP stands for Fractional Part and it returns the fractional part of the argument.

If we're going to have Exp() we're going to need Exp10() as well.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

chris319 wrote:As for other requests, we should be able to use a variable after Step in a For...Next loop. Requiring the use of a constant is ridiculous. And preferably not StepW and StepF, just Step.
:lol: Image that if all the new variable types that are requested are made! We'll need StepB, StepW, StepF, StepUb, StepUw, StepQ, StepUq, StepD and StepLd! No, let's go for the quickstep.
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

I'm a little confused - what does Exp() actually return (obviously value^#E) but whats it for/do?
~I see one problem with your reasoning: the fact is thats not a chicken~
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Killswitch wrote:I'm a little confused - what does Exp() actually return (obviously value^#E) but whats it for/do?
No idea. http://no.php.net/exp
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Post by chris319 »

Sign()
Would you be just as happy with SGN() for compatability with ANSI/ISO and most other BASICs including QB and VB?
Dr. Dri
Enthusiast
Enthusiast
Posts: 243
Joined: Sat Aug 23, 2003 6:45 pm

Post by Dr. Dri »

Killswitch wrote:I'm a little confused - what does Exp() actually return (obviously value^#E) but whats it for/do?
If you lack some skills for math understanding, it's no big deal...
For example Exp() can be used to calculate Pow()

Code: Select all

Procedure.f Exp(x.f)
  Protected r.f, t.f, i.f
  
  If x >= 0
    r = 1.0
    t = 1.0
    
    While t
      i + 1.0
      t * x / i
      r + t
    Wend
  Else
    r = 1/Exp(-x)
  EndIf
  
  ProcedureReturn r
EndProcedure

x.f = 0.485714
y.f = 1.421053

Debug StrF(Pow(x, y), 17)
Debug StrF(Exp(y*Log(x)), 17)
Dri ;)
Intrigued
Enthusiast
Enthusiast
Posts: 501
Joined: Thu Jun 02, 2005 3:55 am
Location: U.S.A.

Post by Intrigued »

we should be able to use a variable after Step in a For...Next loop.
I ran into "needing a variable and not the Constant" deal-e-o in a For..Next loop myself. I second this one!
Intrigued - Registered PureBasic, lifetime updates user
Post Reply