Plse implement ALL Math functions to use extended precision

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Plse implement ALL Math functions to use extended precision

Post by Kaeru Gaman »

oh... and have a nice day.
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Post by Little John »

+ 5 ( + 1 wouldn't really be sufficient. ;-) )

Regards, Little John
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

All math functions comes in single and double precisions. In some case PB use single as it's not explicitely said to use double one.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

Please look into the discussion and give us a hint how we could force double if we want it.

there are some examples where we would expect the double version to be used but the single applies.
oh... and have a nice day.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Fred wrote:All math functions comes in single and double precisions. In some case PB use single as it's not explicitely said to use double one.

Code: Select all

Define.d
double.d = 10
ten.d = 10
value.d = Pow(ten, Log10(double))
Here Log10() uses single precision, that can't be correct.
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

Post by jack »

your example gives the correct result in version 4.02 XP but this crashes in OS X x86 with PB 4.30b4
tried it in the IDE ans shell, same crash.

Code: Select all

Define.d 
double.d = 10 
ten.d = 10 
value.d = Pow(ten, Log10(double))
MessageRequester("", StrD(value,15), 0)
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

I don't know what the correct result would be, I just threw some double variables in there and checked whether the float or double version of the function was called (and it was the float version).
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

Post by jack »

Trond you are right, I was only looking at the output which in this case was correct, a beter test value might be Pi.
here's a snippet of the generated asm

Code: Select all

  FLD    qword [v_double] ;load double, OK
  SUB    esp,4                 ;make room on stack for single, not OK
  FSTP   dword [esp]       ;store double as single, not OK
  CALL  _PB_Log10@4     ;call Log10_single
  SUB    esp,8                 
  FSTP   qword [esp]  
  LEA    edx,[v_ten]        
  PUSH   dword [edx+4]
  PUSH   dword [edx]
  CALL  _PB_Pow_DOUBLE@16
it's OK for Pow but not for Log10
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

The problem with the mail Kaeru refers to is different. It not only has to do with the accuracy of the statement / keyword itself, but also with the way how 'upwards typecasting' doesn't function properly.

Which is, I guess, a bug :-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

yes, it seems to have a bug here.
Post Reply