PDA

View Full Version : Double precision again!


MirceaH
03-10-2004, 04:11 PM
I want to build a DLL which returns double precision numbers (15 digits or so). Whatever I've tried, the returned value (in VB.NET) is always in single precision (6-7 digits). This is the code:

DOUBLE PRECISION FUNCTION TEST_DLL(a) result (c)

DLL_EXPORT TEST_DLL

DOUBLE PRECISION a
DOUBLE PRECISION b
DOUBLE PRECISION c

a=3.1D0
b=1.0D0
c=DPROD(a,b)

RETURN
END

Running the same code in console returns 15 digits precision:

program MyProg
implicit none

DOUBLE PRECISION a
DOUBLE PRECISION b
DOUBLE PRECISION c

a=3.1D0
b=1.0D0
c=DPROD(a,b)

print *,c

end program MyProg

I've read the previous messages about this subject but it seems that it does not work.

tzeis
03-10-2004, 05:37 PM
Try just multiplying the two double precision numbers together without using DPROD. DPROD takes two single precision numbers as arguments, so it might be truncating the values in "a" and "b". If you just say "c = a * b " you will get a double precision result.

MirceaH
03-11-2004, 09:11 AM
Originally posted by tzeis
Try just multiplying the two double precision numbers together without using DPROD. DPROD takes two single precision numbers as arguments, so it might be truncating the values in "a" and "b". If you just say "c = a * b " you will get a double precision result.

Thank you for your replay. However this does not work either! Actually I used DPROD in a disperate attempt to find a solution. :(

MirceaH
03-11-2004, 09:56 AM
Thank you again for the support. Now it works.:)