Discussion about floats and doubles

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Discussion about floats and doubles

Post by Little John »

removed

(I did neither start nor intend this discussion.)
Last edited by Little John on Wed Sep 18, 2013 4:03 pm, edited 3 times in total.
User avatar
KJ67
Enthusiast
Enthusiast
Posts: 218
Joined: Fri Jun 26, 2009 3:51 pm
Location: Westernmost tip of Norway

Re: Extended precision floating-point calculations

Post by KJ67 »

+1, using the native functions and especially on things like log() and sqr() accumulates to rather big deviations since they even on the 64 bit PB only uses floats.
The best preparation for tomorrow is doing your best today.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Extended precision floating-point calculations

Post by freak »

KJ67 wrote:+1, using the native functions and especially on things like log() and sqr() accumulates to rather big deviations since they even on the 64 bit PB only uses floats.
That statement is wrong. These functions use doubles when you store the results in double variables. Doubles are available since v4.00
quidquid Latine dictum sit altum videtur
User avatar
KJ67
Enthusiast
Enthusiast
Posts: 218
Joined: Fri Jun 26, 2009 3:51 pm
Location: Westernmost tip of Norway

Re: Extended precision floating-point calculations

Post by KJ67 »

freak wrote:
KJ67 wrote:+1, using the native functions and especially on things like log() and sqr() accumulates to rather big deviations since they even on the 64 bit PB only uses floats.
That statement is wrong. These functions use doubles when you store the results in double variables. Doubles are available since v4.00
That is very good news and will simplify things, but the documentation header states "Result.f = Sqr(Number.f)", the much wider interpretation of "This function can handle float and double values" was something I missed.
The best preparation for tomorrow is doing your best today.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Extended precision floating-point calculations

Post by freak »

Its on the overview page of the Math library:
Almost all these functions work with floats or doubles, i.e. numbers with the .f or .d extensions. If a function is used with a double value as input or output, it will automatically switch to double precision instead of single precision for its calculations.
quidquid Latine dictum sit altum videtur
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Discussion about floats and doubles

Post by freak »

Locked due to repeated abuse of the topic editing functionality by the OP. If you can't be civilized about it then don't post at all!
quidquid Latine dictum sit altum videtur
Locked