PowD() ?

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
kenmo
Addict
Addict
Posts: 2033
Joined: Tue Dec 23, 2003 3:54 am

PowD() ?

Post by kenmo »

Not mandatory, but has anyone on the PB team looked into a Pow function that returns double precision? I only ask because I'm writing a simple customized calculator program, that uses mostly PB's own functions, and double precision is wasted when Pow is used in a formula.

Thanks
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Pow() is already overloaded and returns a double value when used with doubles.
User avatar
kenmo
Addict
Addict
Posts: 2033
Joined: Tue Dec 23, 2003 3:54 am

Post by kenmo »

Ah, thats good to know. Just wondering, why not overload the Str() functions then, instead of Str() StrF() StrD() StrQ()?

One more question while I'm here, why does StrD() return less precision than the double actually has?

Code: Select all

Pi.d = #PI
Debug Pi
Debug StrD(Pi)
#NULL
Addict
Addict
Posts: 1497
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Post by #NULL »

you can avoid it by specifying a higher nbDecimals parameter.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

kenmo wrote:Ah, thats good to know. Just wondering, why not overload the Str() functions then, instead of Str() StrF() StrD() StrQ()?
It works like this:

Code: Select all

A.d = Pow(2, 3) ; Double version of Pow()
B.f = Pow(2, 3) ; Single version of Pow()
C.s = Str(2) ; StrD() or StrF()???
User avatar
kenmo
Addict
Addict
Posts: 2033
Joined: Tue Dec 23, 2003 3:54 am

Post by kenmo »

#NULL, thanks, I don't know why I didn't think to try that!

Trond, I thought overloading meant slightly different functions with the same name that depended on the type of the input, not the type of the output?
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Trond, I thought overloading meant slightly different functions with the same name that depended on the type of the input, not the type of the output?
It does, and it would be very useful.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

kenmo wrote:#NULL, thanks, I don't know why I didn't think to try that!

Trond, I thought overloading meant slightly different functions with the same name that depended on the type of the input, not the type of the output?
Well, it depends on the output here.
Post Reply