Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Leonhard
User
Posts: 55 Joined: Fri Jun 16, 2006 7:43 am
Post
by Leonhard » Tue May 22, 2007 11:47 am
I need this Operator!
Example:
Code: Select all
Debug 3**4 ;/ Returns 3^4 = Pow(3, 4) = 81
Debug 2**(1/2) ;/ Returns 2^(1/2) = Pow(2, 1/2) = 1,414213...
Derek
Addict
Posts: 2354 Joined: Wed Apr 07, 2004 12:51 am
Location: England
Post
by Derek » Tue May 22, 2007 12:05 pm
But you just showed yourself how to use the pow() command, why do you need ** ?
Psychophanta
Always Here
Posts: 5153 Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:
Post
by Psychophanta » Tue May 22, 2007 1:55 pm
For jokes please go to offtopic area
AND51
Addict
Posts: 1040 Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:
Post
by AND51 » Tue May 22, 2007 4:57 pm
Three Reasons that
support this request:
1) It's much more comfortable to use.
2) It looks more cool.
3) This would also work correctly with Longs (however, Pow accepts Float only).
For the case, that this will be inplemented, please
don't use **. In my opinion ^ is better.
Chrono Syndrome
Enthusiast
Posts: 169 Joined: Thu Oct 05, 2006 6:44 am
Contact:
Post
by Chrono Syndrome » Tue May 22, 2007 5:14 pm
Well, I support zis idea too.
Don't try to catch ze Night !
Remember: 'z' is better zen 'th' =) !
Sorry for bad english.
Deeem2031
Enthusiast
Posts: 216 Joined: Sat Sep 20, 2003 3:57 pm
Location: Germany
Contact:
Post
by Deeem2031 » Tue May 22, 2007 5:28 pm
Code: Select all
Global x, a, *a
x*a
x**a ;(x^a) or (x * *a) ?
x***a
"**" is no good idea
irc://irc.freenode.org/#purebasic
AND51
Addict
Posts: 1040 Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:
Post
by AND51 » Tue May 22, 2007 5:40 pm
That's why I prefer ^
Flype
Addict
Posts: 1542 Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy
Post
by Flype » Tue May 22, 2007 6:26 pm
about ^, yes as many other languages.
but the rules about types conversion should be clearly described before.
type? = var_long ^ var_long
type? = var_long ^ var_float
type? = var_long ^ var_double
...
type? = var_float ^ var_long
type? = var_float ^ var_float
type? = var_float ^ var_double
...
and so on...
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Trond
Always Here
Posts: 7446 Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway
Post
by Trond » Tue May 22, 2007 6:46 pm
Flype wrote: about ^, yes as many other languages.
but the rules about types conversion should be clearly described before.
type? = var_long ^ var_long
type? = var_long ^ var_float
type? = var_long ^ var_double
...
type? = var_float ^ var_long
type? = var_float ^ var_float
type? = var_float ^ var_double
...
and so on...
long ^ long -> long
long ^ float -> float
long ^ double -> double
float ^ long -> float
float ^ float -> float
float ^ double -> double
double ^ * -> double
quad ^ long -> quad
long ^ quad -> quad
quad ^ double -> double
double ^ quad -> double
quad ^ float -> float
float ^ quad -> float
Derek
Addict
Posts: 2354 Joined: Wed Apr 07, 2004 12:51 am
Location: England
Post
by Derek » Wed May 23, 2007 10:32 am
Using ^ would be ok.
Trond wrote:
long ^ long -> long
long ^ float -> float
long ^ double -> double
float ^ long -> float
float ^ float -> float
float ^ double -> double
double ^ * -> double
quad ^ long -> quad
long ^ quad -> quad
quad ^ double -> double =quad
double ^ quad -> double =quad
quad ^ float -> float =quad
float ^ quad -> float =quad
I would of thought that if either argument was a quad then the answer should be quad, same with doubles etc
thefool
Always Here
Posts: 5875 Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark
Post
by thefool » Wed May 23, 2007 10:41 am
Derek wrote: Using ^ would be ok.
Trond wrote:
long ^ long -> long
long ^ float -> float
long ^ double -> double
float ^ long -> float
float ^ float -> float
float ^ double -> double
double ^ * -> double
quad ^ long -> quad
long ^ quad -> quad
quad ^ double -> double =quad
double ^ quad -> double =quad
quad ^ float -> float =quad
float ^ quad -> float =quad
I would of thought that if either argument was a quad then the answer should be quad, same with doubles etc
no. Quads do not support decimals while doubles do, hence result has to be a double.
Derek
Addict
Posts: 2354 Joined: Wed Apr 07, 2004 12:51 am
Location: England
Post
by Derek » Wed May 23, 2007 10:58 am
I just assumed that if you were using quads then you would be going for a higher number rather than a more accurate number including decimals but I guess it could be argued both ways.
thefool
Always Here
Posts: 5875 Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark
Post
by thefool » Wed May 23, 2007 11:20 am
Derek wrote: I just assumed that if you were using quads then you would be going for a higher number rather than a more accurate number including decimals but I guess it could be argued both ways.
Kaeru Gaman
Addict
Posts: 4826 Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany
Post
by Kaeru Gaman » Wed May 23, 2007 12:13 pm
I second the request for ^ as "to the power of"
and I also request an optimized implementation.
if I use only integers and get an integer result, the returned type should be integer, too,
not forced float like the Pow()-Function returns.
additionally, it would be really great if it would be translated into a bitshift (in the asm-code) if the base is a power of two.
oh... and have a nice day.