Page 1 of 2

Add These Functions/Keywords To PureBasic?

Posted: Thu Feb 23, 2006 11:01 pm
by chris319
Should these functions/keywords be added to a future version of PureBasic?

EXP(X)

SGN(X)

PI

-- POLL QUESTION EDITED TO REFLECT INCLUSION OF ACOS(), ASIN() AND ATAN() --

Posted: Thu Feb 23, 2006 11:40 pm
by srod
Are not those last 3 already part of PB?

Posted: Fri Feb 24, 2006 12:49 am
by PB
> Are not those last 3 already part of PB?

Yes. ACos, ASin, and ATan have existed since at least v3.94:
http://www.purebasic.com/documentation/math/index.html

Also, I was certain the constant #PI existed at one time, but I get an error
with v4.00 Beta 3 if I try to use it... surely I couldn't have been dreaming?

EDIT: Ah, here is where I saw it in the manual:
http://www.purebasic.com/documentation/ ... mulas.html

It says to use PI, but I do "Debug PI" it returns 0 for v4.00 Beta 3. Looks
like it needs fixing for v4.00 Final.

Posted: Fri Feb 24, 2006 3:32 pm
by Jan Vooijs
PB

Here is PI:

Code: Select all

Debug ACos(-1)
Now hows that a program in one line giving PI!!!!

The answer is: 3.1415927410125732

Posted: Fri Feb 24, 2006 3:56 pm
by PB
> Here is PI:
> Debug ACos(-1)

Hehe, and here's a macro for it (until Fred fixes the PI variable):

Code: Select all

Macro Pie
  ACos(-1)
EndMacro

Debug Pie
;)

Posted: Fri Feb 24, 2006 4:00 pm
by Dare2
What about just:

#PI = 3.1415927410125732

:)


BTW, I don't think PureBasic ever had Pi, did it?

Posted: Fri Feb 24, 2006 4:05 pm
by PB
> I don't think PureBasic ever had Pi, did it?

According to the manual/helpfile, yes. See my link above.

Posted: Fri Feb 24, 2006 4:15 pm
by Dare2
Ah.

I think it meant Pi in a general sense as it also shows the Acos(-1) to get Pi. I just tried in 3.94 and pi = 0, "pi" being a long, pi.l

Regardless, we now have pi in several flavours. And macros are going to save Fred and team from writing some commands/fielding some requests down the track, I think. ;)

Posted: Sat Feb 25, 2006 5:08 am
by chris319
This is from the online documentation for 3.94:

Code: Select all

Command Index

    ACos
    ASin
    ATan
    Abs
    Cos
    Int
    Log
    Log10
    Pow
    Round
    Sin
    Sqr
    Tan
No PI.

Bottom line: PI, EXP() AND SGN() are not needed. They are not needed because ... ?
pi = 0, "pi" being a long, pi.l
I would expect PI to be a float or a double, wouldn't you?

Posted: Sat Feb 25, 2006 5:13 am
by Flype
#PI (PB4B4) is a double :wink:

Posted: Sat Feb 25, 2006 5:27 am
by PB
> No PI

Well the manual gives an example in "PureBasic code" as you can see:

Code: Select all

'PI' stands for the constant value "PI = 3.1415...". An example for realizing
such a formula in PureBasic code: A = PI*r^2 will be A = PI*Pow(r,2)
So I thought PI was a reserved variable or something. As I never had to use
PI, I never tested it before, and just assumed it worked per the above code.
But good to see that Fred has officially added it as #PI for the next release. :)

Posted: Sat Feb 25, 2006 3:33 pm
by Jan Vooijs
PB wrote:> Here is PI:
> Debug ACos(-1)

Hehe, and here's a macro for it (until Fred fixes the PI variable):

Code: Select all

Macro Pie
  ACos(-1)
EndMacro

Debug Pie
;)
Your version looks more like a-PIE-in-the-Sky :oops: :lol: :P :roll: :D

Jan V. (no pun intended)

Posted: Sat Feb 25, 2006 3:38 pm
by PB
:lol: @Jan.

Posted: Sun Feb 26, 2006 4:23 am
by chris319
The PureBasic lot are a funny, funny lot.
#PI (PB4B4) is a double
One out of three ain't bad.

Posted: Sun Feb 26, 2006 4:32 am
by Dare2
Debug pi in 3.94 is debugging a long. :) Does that make it 2 out of 3? :)