Frank Heckenbach wrote:
Prof Abimbola Olowofoyeku wrote:
Would you like to answer two questions about GNU Pascal (MS DOS with
DGJPP) for which I haven't found the answer in documentation? I work in
MS-DOS under Windows 98 (processor Pentium II).
- Is it possible to force the functions sin, cos, exp, ln, **, etc. to
calculate a result of type LongReal (10 bytes) with a precision of 19
decimal digits (as in BP or Delphi)?
Dunno. But I would be surprised if it wasn't.
This happens automatically if the system library provides `sinl'
etc. functions. This doesn't seem to be the case under DJGPP. So you
might want to ask the DJGPP developers if/when this will be
supported (should be rather easy to do, they'd basically have to
copy the code from Linux/IA32, I guess).
I use a workaround meanwhile.
There is a free library which contains all these functions: the CEPHES library
available at
http://www.moshier.net/#Cephes
Download cephes28.zip, the MSDOS distribution, and compile the ldouble library
(contained in the ldouble sundirectory): you will need to check the makefile
and mconf.h : some parameters correspond to the linux case.
You will get a libml.a library you will put in the %DJDIR%\lib standard DJGPP
library directory.
To use it from gpc you will need an import unit. I attach the one I use.
Simply put
uses libml, ...
in your main program tu use it.
In this unit you will probably have to comment out the declararations
for the operators pow and ** until the bug I reported in an other mail will
be corrected (meanwhile you can copy the declarations into your main program).
Also probably not all transcendental functions are imported:
it contains the ones I have used up to now with pascal names according to my taste.
In fact it is possible now to integrate this library into libm.a, and to compile
gpc so that gpc knows automatically all the standard pascal functions
(the "standard pascal" functions flagged in the libml.pas import unit).
But you will need anyway the import unit for the other transcendantal
functions so that I find rather useless to publish a special version
of gpc which would incorporate this stuff.
Maurice
--
Maurice Lombardi
Laboratoire de Spectrometrie Physique,
Universite Joseph Fourier de Grenoble, BP87
38402 Saint Martin d'Heres Cedex FRANCE
Tel: 33 (0)4 76 51 47 51
Fax: 33 (0)4 76 63 54 95
mailto:Maurice.Lombardi@ujf-grenoble.fr
UNIT libml;
INTERFACE
{standard pascal}
function sqrt(x:LongReal):LongReal; Asmname 'sqrtl';
function exp(x:LongReal):LongReal; Asmname 'expl';
function ln(x:LongReal):LongReal; Asmname 'logl';
operator pow(x:LongReal;i:integer) r:LongReal; Asmname 'powil';
operator **(x,y:LongReal) r:LongReal; Asmname 'powl';
function sin(x:LongReal):LongReal; Asmname 'sinl';
function cos(x:LongReal):LongReal; Asmname 'cosl';
function arctan(x:LongReal):LongReal; Asmname 'atanl';
{extra}
function ExpMoinsUn(x:LongReal): LongReal; Asmname 'expm1l';
function LnUnPlus(x:LongReal): LongReal; AsmName 'log1pl';
function CosMoinsUn(x:LongReal): LongReal; AsmName 'cosm1l';
function DixPuiss(x:LongReal):LongReal; Asmname 'exp10l';
function DeuPuiss(x:LongReal):LongReal; AsmName 'exp2l';
function log10(x:LongReal):LongReal; Asmname 'log10l';
function log2(x:LongReal):LongReal; Asmname 'log2l';
{extra trigo}
function tan(x:LongReal):LongReal; Asmname 'tanl';
function cotan(x:LongReal):LongReal; AsmName 'cotl';
function arcsin(x:LongReal):LongReal; Asmname 'asinl';
function arccos(x:LongReal):LongReal; Asmname 'acosl';
function arctan2(y,x:LongReal):LongReal; AsmName 'atan2l';
function sinh(x:LongReal):LongReal; Asmname 'sinhl';
function cosh(x:LongReal):LongReal; Asmname 'coshl';
function tanh(x:LongReal):LongReal; Asmname 'tanhl';
function asinh(x:LongReal):LongReal; Asmname 'asinhl';
function acosh(x:LongReal):LongReal; Asmname 'acoshl';
function atanh(x:LongReal):LongReal; Asmname 'atanhl';
{extra transcendental}
function Gamma(x:LongReal):LongReal; AsmName 'gammal';
function lnGamma(x:LongReal):LongReal; AsmName 'lgaml';
function Elliptic_Complete_Kp(m1:Longreal): LongReal; AsmName 'ellpkl';
function Elliptic_Complete_Ep(m1:Longreal): LongReal; AsmName 'ellpel';
function Elliptic_InComplete_F(phi,m:Longreal): LongReal; AsmName 'ellikl';
function Elliptic_InComplete_E(phi,m:Longreal): LongReal; AsmName 'elliel';
function BessJ0(x:LongReal): LongReal; AsmName 'j0l';
function BessY0(x:LongReal): LongReal; AsmName 'y0l';
function BessJ1(x:LongReal): LongReal; AsmName 'j1l';
function BessY1(x:LongReal): LongReal; AsmName 'y1l';
function BessJn(n:integer;x:LongReal): LongReal; AsmName 'jnl';
function ArcXY(x,y:LongReal):LongReal; { [0, 2 pi[ }
IMPLEMENTATION
function ArcXY(x,y:LongReal) a :LongReal; { [0, 2 pi[ }
begin
a:=arctan2(y,x); {ANSI C: ordre y,x et [-pi, pi[}
if a < 0 then a:=a+2*pi;
end;
{$L ml}
end.