4
Contains: FPCE Floating-Point Definitions and Declarations.
6
Version: Technology: MathLib v2
7
Release: Universal Interfaces 3.4.2
9
Copyright: � 1987-2002 by Apple Computer, Inc., all rights reserved.
11
Bugs?: For bug reports, consult the following page on
14
http://www.freepascal.org/bugs.html
19
Modified for use with Free Pascal
21
Please report any bugs to <gpc@microbizz.nl>
32
{$setc UNIVERSAL_INTERFACES_VERSION := $0342}
33
{$setc GAP_INTERFACES_VERSION := $0200}
35
{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
36
{$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
39
{$ifc defined CPUPOWERPC and defined CPUI386}
40
{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
42
{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
43
{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
46
{$ifc not defined __ppc__ and defined CPUPOWERPC}
51
{$ifc not defined __i386__ and defined CPUI386}
57
{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
58
{$error Conflicting definitions for __ppc__ and __i386__}
61
{$ifc defined __ppc__ and __ppc__}
62
{$setc TARGET_CPU_PPC := TRUE}
63
{$setc TARGET_CPU_X86 := FALSE}
64
{$elifc defined __i386__ and __i386__}
65
{$setc TARGET_CPU_PPC := FALSE}
66
{$setc TARGET_CPU_X86 := TRUE}
68
{$error Neither __ppc__ nor __i386__ is defined.}
70
{$setc TARGET_CPU_PPC_64 := FALSE}
72
{$ifc defined FPC_BIG_ENDIAN}
73
{$setc TARGET_RT_BIG_ENDIAN := TRUE}
74
{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
75
{$elifc defined FPC_LITTLE_ENDIAN}
76
{$setc TARGET_RT_BIG_ENDIAN := FALSE}
77
{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
79
{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
81
{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
82
{$setc CALL_NOT_IN_CARBON := FALSE}
83
{$setc OLDROUTINENAMES := FALSE}
84
{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
85
{$setc OPAQUE_UPP_TYPES := TRUE}
86
{$setc OTCARBONAPPLICATION := TRUE}
87
{$setc OTKERNEL := FALSE}
88
{$setc PM_USE_SESSION_APIS := TRUE}
89
{$setc TARGET_API_MAC_CARBON := TRUE}
90
{$setc TARGET_API_MAC_OS8 := FALSE}
91
{$setc TARGET_API_MAC_OSX := TRUE}
92
{$setc TARGET_CARBON := TRUE}
93
{$setc TARGET_CPU_68K := FALSE}
94
{$setc TARGET_CPU_MIPS := FALSE}
95
{$setc TARGET_CPU_SPARC := FALSE}
96
{$setc TARGET_OS_MAC := TRUE}
97
{$setc TARGET_OS_UNIX := FALSE}
98
{$setc TARGET_OS_WIN32 := FALSE}
99
{$setc TARGET_RT_MAC_68881 := FALSE}
100
{$setc TARGET_RT_MAC_CFM := FALSE}
101
{$setc TARGET_RT_MAC_MACHO := TRUE}
102
{$setc TYPED_FUNCTION_POINTERS := TRUE}
103
{$setc TYPE_BOOL := FALSE}
104
{$setc TYPE_EXTENDED := FALSE}
105
{$setc TYPE_LONGLONG := TRUE}
106
uses MacTypes,ConditionalMacros;
108
{*******************************************************************************
110
* A collection of numerical functions designed to facilitate a wide *
111
* range of numerical programming as required by C9X. *
113
* The <fp.h> declares many functions in support of numerical programming. *
114
* It provides a superset of <math.h> and <SANE.h> functions. Some *
115
* functionality previously found in <SANE.h> and not in the FPCE <fp.h> *
116
* can be found in this <fp.h> under the heading "__NOEXTENSIONS__". *
118
* All of these functions are IEEE 754 aware and treat exceptions, NaNs, *
119
* positive and negative zero and infinity consistent with the floating- *
122
*******************************************************************************}
127
{*******************************************************************************
131
* float_t Most efficient type at least as wide as float *
132
* double_t Most efficient type at least as wide as double *
134
* CPU float_t(bits) double_t(bits) *
135
* -------- ----------------- ----------------- *
136
* PowerPC float(32) double(64) *
137
* 68K long double(80/96) long double(80/96) *
138
* x86 double(64) double(64) *
140
*******************************************************************************}
141
{$ifc TARGET_CPU_PPC}
147
{$ifc TARGET_CPU_68K}
152
{$ifc TARGET_CPU_X86}
158
{$ifc TARGET_CPU_MIPS}
164
{$ifc TARGET_CPU_ALPHA}
170
{$ifc TARGET_CPU_SPARC}
184
{*******************************************************************************
186
* Define some constants. *
188
* HUGE_VAL IEEE 754 value of infinity. *
189
* INFINITY IEEE 754 value of infinity. *
190
* NAN A generic NaN (Not A Number). *
191
* DECIMAL_DIG Satisfies the constraint that the conversion from *
192
* double to decimal and back is the identity function. *
194
*******************************************************************************}
196
{$ifc TARGET_CPU_PPC}
202
{*******************************************************************************
204
* Trigonometric functions *
206
* acos result is in [0,pi]. *
207
* asin result is in [-pi/2,pi/2]. *
208
* atan result is in [-pi/2,pi/2]. *
209
* atan2 Computes the arc tangent of y/x in [-pi,pi] using the sign of *
210
* both arguments to determine the quadrant of the computed value. *
212
*******************************************************************************}
217
* Non-Carbon CFM: in MathLib 1.0 and later
218
* CarbonLib: in CarbonLib 1.0 and later
219
* Mac OS X: in version 10.0 and later
221
function cos(x: double_t): double_t; external name '_cos';
227
* Non-Carbon CFM: in MathLib 1.0 and later
228
* CarbonLib: in CarbonLib 1.0 and later
229
* Mac OS X: in version 10.0 and later
231
function sin(x: double_t): double_t; external name '_sin';
237
* Non-Carbon CFM: in MathLib 1.0 and later
238
* CarbonLib: in CarbonLib 1.0 and later
239
* Mac OS X: in version 10.0 and later
241
function tan(x: double_t): double_t; external name '_tan';
247
* Non-Carbon CFM: in MathLib 1.0 and later
248
* CarbonLib: in CarbonLib 1.0 and later
249
* Mac OS X: in version 10.0 and later
251
function acos(x: double_t): double_t; external name '_acos';
257
* Non-Carbon CFM: in MathLib 1.0 and later
258
* CarbonLib: in CarbonLib 1.0 and later
259
* Mac OS X: in version 10.0 and later
261
function asin(x: double_t): double_t; external name '_asin';
267
* Non-Carbon CFM: in MathLib 1.0 and later
268
* CarbonLib: in CarbonLib 1.0 and later
269
* Mac OS X: in version 10.0 and later
271
function atan(x: double_t): double_t; external name '_atan';
277
* Non-Carbon CFM: in MathLib 1.0 and later
278
* CarbonLib: in CarbonLib 1.0 and later
279
* Mac OS X: in version 10.0 and later
281
function atan2(y: double_t; x: double_t): double_t; external name '_atan2';
284
{*******************************************************************************
286
* Hyperbolic functions *
288
*******************************************************************************}
293
* Non-Carbon CFM: in MathLib 1.0 and later
294
* CarbonLib: in CarbonLib 1.0 and later
295
* Mac OS X: in version 10.0 and later
297
function cosh(x: double_t): double_t; external name '_cosh';
303
* Non-Carbon CFM: in MathLib 1.0 and later
304
* CarbonLib: in CarbonLib 1.0 and later
305
* Mac OS X: in version 10.0 and later
307
function sinh(x: double_t): double_t; external name '_sinh';
313
* Non-Carbon CFM: in MathLib 1.0 and later
314
* CarbonLib: in CarbonLib 1.0 and later
315
* Mac OS X: in version 10.0 and later
317
function tanh(x: double_t): double_t; external name '_tanh';
323
* Non-Carbon CFM: in MathLib 1.0 and later
324
* CarbonLib: in CarbonLib 1.0 and later
325
* Mac OS X: in version 10.0 and later
327
function acosh(x: double_t): double_t; external name '_acosh';
333
* Non-Carbon CFM: in MathLib 1.0 and later
334
* CarbonLib: in CarbonLib 1.0 and later
335
* Mac OS X: in version 10.0 and later
337
function asinh(x: double_t): double_t; external name '_asinh';
343
* Non-Carbon CFM: in MathLib 1.0 and later
344
* CarbonLib: in CarbonLib 1.0 and later
345
* Mac OS X: in version 10.0 and later
347
function atanh(x: double_t): double_t; external name '_atanh';
350
{*******************************************************************************
352
* Exponential functions *
354
* expm1 expm1(x) = exp(x) - 1. But, for small enough arguments, *
355
* expm1(x) is expected to be more accurate than exp(x) - 1. *
356
* frexp Breaks a floating-point number into a normalized fraction *
357
* and an integral power of 2. It stores the SInt16 in the *
358
* object pointed by *exponent. *
359
* ldexp Multiplies a floating-point number by an SInt16 power of 2. *
360
* log1p log1p = log(1 + x). But, for small enough arguments, *
361
* log1p is expected to be more accurate than log(1 + x). *
362
* logb Extracts the exponent of its argument, as a signed integral *
363
* value. A subnormal argument is treated as though it were first *
364
* normalized. Thus: *
365
* 1 <= x * 2^(-logb(x)) < 2 *
366
* modf Returns fractional part of x as function result and returns *
367
* integral part of x via iptr. Note C9X uses double not double_t. *
368
* scalb Computes x * 2^n efficently. This is not normally done by *
369
* computing 2^n explicitly. *
371
*******************************************************************************}
376
* Non-Carbon CFM: in MathLib 1.0 and later
377
* CarbonLib: in CarbonLib 1.0 and later
378
* Mac OS X: in version 10.0 and later
380
function exp(x: double_t): double_t; external name '_exp';
386
* Non-Carbon CFM: in MathLib 1.0 and later
387
* CarbonLib: in CarbonLib 1.0 and later
388
* Mac OS X: in version 10.0 and later
390
function expm1(x: double_t): double_t; external name '_expm1';
396
* Non-Carbon CFM: in MathLib 1.0 and later
397
* CarbonLib: in CarbonLib 1.0 and later
398
* Mac OS X: in version 10.0 and later
400
function exp2(x: double_t): double_t; external name '_exp2';
406
* Non-Carbon CFM: in MathLib 1.0 and later
407
* CarbonLib: in CarbonLib 1.0 and later
408
* Mac OS X: in version 10.0 and later
410
function frexp(x: double_t; var exponent: SInt32): double_t; external name '_frexp';
416
* Non-Carbon CFM: in MathLib 1.0 and later
417
* CarbonLib: in CarbonLib 1.0 and later
418
* Mac OS X: in version 10.0 and later
420
function ldexp(x: double_t; n: SInt32): double_t; external name '_ldexp';
426
* Non-Carbon CFM: in MathLib 1.0 and later
427
* CarbonLib: in CarbonLib 1.0 and later
428
* Mac OS X: in version 10.0 and later
430
function log(x: double_t): double_t; external name '_log';
436
* Non-Carbon CFM: in MathLib 1.0 and later
437
* CarbonLib: in CarbonLib 1.0 and later
438
* Mac OS X: in version 10.0 and later
440
function log2(x: double_t): double_t; external name '_log2';
446
* Non-Carbon CFM: in MathLib 1.0 and later
447
* CarbonLib: in CarbonLib 1.0 and later
448
* Mac OS X: in version 10.0 and later
450
function log1p(x: double_t): double_t; external name '_log1p';
456
* Non-Carbon CFM: in MathLib 1.0 and later
457
* CarbonLib: in CarbonLib 1.0 and later
458
* Mac OS X: in version 10.0 and later
460
function log10(x: double_t): double_t; external name '_log10';
466
* Non-Carbon CFM: in MathLib 1.0 and later
467
* CarbonLib: in CarbonLib 1.0 and later
468
* Mac OS X: in version 10.0 and later
470
function logb(x: double_t): double_t; external name '_logb';
476
* Non-Carbon CFM: in MathLib 1.0 and later
477
* CarbonLib: in CarbonLib 1.0 and later
478
* Mac OS X: in version 10.0 and later
480
function modf(x: double_t; var iptr: double_t): double_t; external name '_modf';
486
* Non-Carbon CFM: in MathLib 1.0 and later
487
* CarbonLib: in CarbonLib 1.0 and later
488
* Mac OS X: in version 10.0 and later
490
function modff(x: Single; var iptrf: Single): Single; external name '_modff';
494
Note: For compatiblity scalb(x,n) has n of type
500
_scalb_n_type = SInt32;
505
* Non-Carbon CFM: in MathLib 1.0 and later
506
* CarbonLib: in CarbonLib 1.0 and later
507
* Mac OS X: in version 10.0 and later
509
function scalb(x: double_t; n: _scalb_n_type): double_t; external name '_scalb';
512
{*******************************************************************************
514
* Power and absolute value functions *
516
* hypot Computes the square root of the sum of the squares of its *
517
* arguments, without undue overflow or underflow. *
518
* pow Returns x raised to the power of y. Result is more accurate *
519
* than using exp(log(x)*y). *
521
*******************************************************************************}
526
* Non-Carbon CFM: in MathLib 1.0 and later
527
* CarbonLib: in CarbonLib 1.0 and later
528
* Mac OS X: in version 10.0 and later
530
function fabs(x: double_t): double_t; external name '_fabs';
536
* Non-Carbon CFM: in MathLib 1.0 and later
537
* CarbonLib: in CarbonLib 1.0 and later
538
* Mac OS X: in version 10.0 and later
540
function hypot(x: double_t; y: double_t): double_t; external name '_hypot';
546
* Non-Carbon CFM: in MathLib 2.0 and later
547
* CarbonLib: in CarbonLib 1.0 and later
548
* Mac OS X: in version 10.0 and later
550
function pow(x: double_t; y: double_t): double_t; external name '_pow';
556
* Non-Carbon CFM: in MathLib 1.0 and later
557
* CarbonLib: in CarbonLib 1.0 and later
558
* Mac OS X: in version 10.0 and later
560
function sqrt(x: double_t): double_t; external name '_sqrt';
563
{*******************************************************************************
565
* Gamma and Error functions *
567
* erf The error function. *
568
* erfc Complementary error function. *
569
* gamma The gamma function. *
570
* lgamma Computes the base-e logarithm of the absolute value of *
571
* gamma of its argument x, for x > 0. *
573
*******************************************************************************}
578
* Non-Carbon CFM: in MathLib 1.0 and later
579
* CarbonLib: in CarbonLib 1.0 and later
580
* Mac OS X: in version 10.0 and later
582
function erf(x: double_t): double_t; external name '_erf';
588
* Non-Carbon CFM: in MathLib 1.0 and later
589
* CarbonLib: in CarbonLib 1.0 and later
590
* Mac OS X: in version 10.0 and later
592
function erfc(x: double_t): double_t; external name '_erfc';
598
* Non-Carbon CFM: in MathLib 1.0 and later
599
* CarbonLib: in CarbonLib 1.0 and later
600
* Mac OS X: in version 10.0 and later
602
function gamma(x: double_t): double_t; external name '_gamma';
608
* Non-Carbon CFM: in MathLib 1.0 and later
609
* CarbonLib: in CarbonLib 1.0 and later
610
* Mac OS X: in version 10.0 and later
612
function lgamma(x: double_t): double_t; external name '_lgamma';
615
{*******************************************************************************
617
* Nearest SInt16 functions *
619
* rint Rounds its argument to an integral value in floating point *
620
* format, honoring the current rounding direction. *
622
* nearbyint Differs from rint only in that it does not raise the inexact *
623
* exception. It is the nearbyint function recommended by the *
624
* IEEE floating-point standard 854. *
626
* rinttol Rounds its argument to the nearest long int using the current *
627
* rounding direction. NOTE: if the rounded value is outside *
628
* the range of long int, then the result is undefined. *
630
* round Rounds the argument to the nearest integral value in floating *
631
* point format similar to the Fortran "anint" function. That is: *
632
* add half to the magnitude and chop. *
634
* roundtol Similar to the Fortran function nint or to the Pascal round. *
635
* NOTE: if the rounded value is outside the range of long int, *
636
* then the result is undefined. *
638
* trunc Computes the integral value, in floating format, nearest to *
639
* but no larger in magnitude than its argument. NOTE: on 68K *
640
* compilers when using -elems881, trunc must return an int *
642
*******************************************************************************}
647
* Non-Carbon CFM: in MathLib 1.0 and later
648
* CarbonLib: in CarbonLib 1.0 and later
649
* Mac OS X: in version 10.0 and later
651
function ceil(x: double_t): double_t; external name '_ceil';
657
* Non-Carbon CFM: in MathLib 1.0 and later
658
* CarbonLib: in CarbonLib 1.0 and later
659
* Mac OS X: in version 10.0 and later
661
function floor(x: double_t): double_t; external name '_floor';
667
* Non-Carbon CFM: in MathLib 1.0 and later
668
* CarbonLib: in CarbonLib 1.0 and later
669
* Mac OS X: in version 10.0 and later
671
function rint(x: double_t): double_t; external name '_rint';
677
* Non-Carbon CFM: in MathLib 1.0 and later
678
* CarbonLib: in CarbonLib 1.0 and later
679
* Mac OS X: in version 10.0 and later
681
function nearbyint(x: double_t): double_t; external name '_nearbyint';
687
* Non-Carbon CFM: in MathLib 1.0 and later
688
* CarbonLib: in CarbonLib 1.0 and later
689
* Mac OS X: in version 10.0 and later
691
function rinttol(x: double_t): SInt32; external name '_rinttol';
697
* Non-Carbon CFM: in MathLib 1.0 and later
698
* CarbonLib: in CarbonLib 1.0 and later
699
* Mac OS X: in version 10.0 and later
701
function roundd(x: double_t): double_t; external name '_round';
707
* Non-Carbon CFM: in MathLib 1.0 and later
708
* CarbonLib: in CarbonLib 1.0 and later
709
* Mac OS X: in version 10.0 and later
711
function roundtol(round: double_t): SInt32; external name '_roundtol';
714
Note: For compatiblity trunc(x) has a return type of
715
int for classic 68K with FPU enabled
716
double_t everywhere else
718
{$ifc TARGET_RT_MAC_68881}
721
_trunc_return_type = SInt32;
725
_trunc_return_type = double_t;
726
{$endc} {TARGET_RT_MAC_68881}
731
* Non-Carbon CFM: in MathLib 1.0 and later
732
* CarbonLib: in CarbonLib 1.0 and later
733
* Mac OS X: in version 10.0 and later
735
function truncd(x: double_t): _trunc_return_type; external name '_trunc';
738
{*******************************************************************************
740
* Remainder functions *
742
* remainder IEEE 754 floating point standard for remainder. *
743
* remquo SANE remainder. It stores into 'quotient' the 7 low-order *
744
* bits of the SInt16 quotient x/y, such that: *
745
* -127 <= quotient <= 127. *
747
*******************************************************************************}
752
* Non-Carbon CFM: in MathLib 1.0 and later
753
* CarbonLib: in CarbonLib 1.0 and later
754
* Mac OS X: in version 10.0 and later
756
function fmod(x: double_t; y: double_t): double_t; external name '_fmod';
762
* Non-Carbon CFM: in MathLib 1.0 and later
763
* CarbonLib: in CarbonLib 1.0 and later
764
* Mac OS X: in version 10.0 and later
766
function remainder(x: double_t; y: double_t): double_t; external name '_remainder';
772
* Non-Carbon CFM: in MathLib 1.0 and later
773
* CarbonLib: in CarbonLib 1.0 and later
774
* Mac OS X: in version 10.0 and later
776
function remquo(x: double_t; y: double_t; var quo: SInt32): double_t; external name '_remquo';
779
{*******************************************************************************
781
* Auxiliary functions *
783
* copysign Produces a value with the magnitude of its first argument *
784
* and sign of its second argument. NOTE: the order of the *
785
* arguments matches the recommendation of the IEEE 754 *
786
* floating point standard, which is opposite from the SANE *
787
* copysign function. *
789
* nan The call 'nan("n-char-sequence")' returns a quiet NaN *
790
* with content indicated through tagp in the selected *
791
* data type format. *
793
* nextafter Computes the next representable value after 'x' in the *
794
* direction of 'y'. if x == y, then y is returned. *
796
*******************************************************************************}
801
* Non-Carbon CFM: in MathLib 1.0 and later
802
* CarbonLib: in CarbonLib 1.0 and later
803
* Mac OS X: in version 10.0 and later
805
function copysign(x: double_t; y: double_t): double_t; external name '_copysign';
811
* Non-Carbon CFM: in MathLib 1.0 and later
812
* CarbonLib: in CarbonLib 1.0 and later
813
* Mac OS X: in version 10.0 and later
815
function nan(tagp: ConstCStringPtr): Double; external name '_nan';
821
* Non-Carbon CFM: in MathLib 1.0 and later
822
* CarbonLib: in CarbonLib 1.0 and later
823
* Mac OS X: in version 10.0 and later
825
function nanf(tagp: ConstCStringPtr): Single; external name '_nanf';
831
* Non-Carbon CFM: in MathLib 1.0 and later
832
* CarbonLib: in CarbonLib 1.0 and later
833
* Mac OS X: in version 10.0 and later
835
function nextafterd(x: Double; y: Double): Double; external name '_nextafterd';
841
* Non-Carbon CFM: in MathLib 1.0 and later
842
* CarbonLib: in CarbonLib 1.0 and later
843
* Mac OS X: in version 10.0 and later
845
function nextafterf(x: Single; y: Single): Single; external name '_nextafterf';
852
* Non-Carbon CFM: in MathLib 1.0 and later
853
* CarbonLib: in CarbonLib 1.0 and later
854
* Mac OS X: in version 10.0 and later
856
function __fpclassifyd(x: Double): SInt32; external name '___fpclassifyd';
862
* Non-Carbon CFM: in MathLib 1.0 and later
863
* CarbonLib: in CarbonLib 1.0 and later
864
* Mac OS X: in version 10.0 and later
866
function __fpclassifyf(x: Single): SInt32; external name '___fpclassifyf';
872
* Non-Carbon CFM: in MathLib 1.0 and later
873
* CarbonLib: in CarbonLib 1.0 and later
874
* Mac OS X: in version 10.0 and later
876
function __isnormald(x: Double): SInt32; external name '___isnormald';
882
* Non-Carbon CFM: in MathLib 1.0 and later
883
* CarbonLib: in CarbonLib 1.0 and later
884
* Mac OS X: in version 10.0 and later
886
function __isnormalf(x: Single): SInt32; external name '___isnormalf';
892
* Non-Carbon CFM: in MathLib 1.0 and later
893
* CarbonLib: in CarbonLib 1.0 and later
894
* Mac OS X: in version 10.0 and later
896
function __isfinited(x: Double): SInt32; external name '___isfinited';
902
* Non-Carbon CFM: in MathLib 1.0 and later
903
* CarbonLib: in CarbonLib 1.0 and later
904
* Mac OS X: in version 10.0 and later
906
function __isfinitef(x: Single): SInt32; external name '___isfinitef';
912
* Non-Carbon CFM: in MathLib 1.0 and later
913
* CarbonLib: in CarbonLib 1.0 and later
914
* Mac OS X: in version 10.0 and later
916
function __isnand(x: Double): SInt32; external name '___isnand';
922
* Non-Carbon CFM: in MathLib 1.0 and later
923
* CarbonLib: in CarbonLib 1.0 and later
924
* Mac OS X: in version 10.0 and later
926
function __isnanf(x: Single): SInt32; external name '___isnanf';
932
* Non-Carbon CFM: in MathLib 1.0 and later
933
* CarbonLib: in CarbonLib 1.0 and later
934
* Mac OS X: in version 10.0 and later
936
function __signbitd(x: Double): SInt32; external name '___signbitd';
942
* Non-Carbon CFM: in MathLib 1.0 and later
943
* CarbonLib: in CarbonLib 1.0 and later
944
* Mac OS X: in version 10.0 and later
946
function __signbitf(x: Single): SInt32; external name '___signbitf';
952
* Non-Carbon CFM: in MathLib 1.0 and later
953
* CarbonLib: in CarbonLib 1.0 and later
954
* Mac OS X: in version 10.0 and later
956
function __inf: double_t; external name '___inf';
959
{*******************************************************************************
963
* fpclassify Returns one of the FP_� values. *
964
* isnormal Non-zero if and only if the argument x is normalized. *
965
* isfinite Non-zero if and only if the argument x is finite. *
966
* isnan Non-zero if and only if the argument x is a NaN. *
967
* signbit Non-zero if and only if the sign of the argument x is *
968
* negative. This includes, NaNs, infinities and zeros. *
970
*******************************************************************************}
973
FP_SNAN = 0; { signaling NaN }
974
FP_QNAN = 1; { quiet NaN }
975
FP_INFINITE = 2; { + or - infinity }
976
FP_ZERO = 3; { + or - zero }
977
FP_NORMAL = 4; { all normal numbers }
978
FP_SUBNORMAL = 5; { denormal numbers }
981
{ *******************************************************************************
983
* Max, Min and Positive Difference *
985
* fdim Determines the 'positive difference' between its arguments: *
986
* ( x - y, if x > y ), ( +0, if x <= y ). If one argument is *
987
* NaN, then fdim returns that NaN. if both arguments are NaNs, *
988
* then fdim returns the first argument. *
990
* fmax Returns the maximum of the two arguments. Corresponds to the *
991
* max function in FORTRAN. NaN arguments are treated as missing *
992
* data. If one argument is NaN and the other is a number, then *
993
* the number is returned. If both are NaNs then the first *
994
* argument is returned. *
996
* fmin Returns the minimum of the two arguments. Corresponds to the *
997
* min function in FORTRAN. NaN arguments are treated as missing *
998
* data. If one argument is NaN and the other is a number, then *
999
* the number is returned. If both are NaNs then the first *
1000
* argument is returned. *
1002
******************************************************************************* }
1007
* Non-Carbon CFM: in MathLib 1.0 and later
1008
* CarbonLib: in CarbonLib 1.0 and later
1009
* Mac OS X: in version 10.0 and later
1011
function fdim(x: double_t; y: double_t): double_t; external name '_fdim';
1017
* Non-Carbon CFM: in MathLib 1.0 and later
1018
* CarbonLib: in CarbonLib 1.0 and later
1019
* Mac OS X: in version 10.0 and later
1021
function fmax(x: double_t; y: double_t): double_t; external name '_fmax';
1027
* Non-Carbon CFM: in MathLib 1.0 and later
1028
* CarbonLib: in CarbonLib 1.0 and later
1029
* Mac OS X: in version 10.0 and later
1031
function fmin(x: double_t; y: double_t): double_t; external name '_fmin';
1034
{******************************************************************************
1036
******************************************************************************}
1038
{*******************************************************************************
1040
* Non NCEG extensions *
1042
*******************************************************************************}
1043
{$ifc undefined __NOEXTENSIONS__}
1044
{*******************************************************************************
1046
* Financial functions *
1048
* compound Computes the compound interest factor "(1 + rate)^periods" *
1049
* more accurately than the straightforward computation with *
1050
* the Power function. This is SANE's compound function. *
1052
* annuity Computes the present value factor for an annuity *
1053
* "(1 - (1 + rate)^(-periods)) /rate" more accurately than *
1054
* the straightforward computation with the Power function. *
1055
* This is SANE's annuity function. *
1057
*******************************************************************************}
1062
* Non-Carbon CFM: in MathLib 1.0 and later
1063
* CarbonLib: in CarbonLib 1.0 and later
1064
* Mac OS X: in version 10.0 and later
1066
function compound(rate: double_t; periods: double_t): double_t; external name '_compound';
1072
* Non-Carbon CFM: in MathLib 1.0 and later
1073
* CarbonLib: in CarbonLib 1.0 and later
1074
* Mac OS X: in version 10.0 and later
1076
function annuity(rate: double_t; periods: double_t): double_t; external name '_annuity';
1079
{*******************************************************************************
1083
* randomx A pseudorandom number generator. It uses the iteration: *
1084
* (7^5*x)mod(2^31-1) *
1086
*******************************************************************************}
1091
* Non-Carbon CFM: in MathLib 1.0 and later
1092
* CarbonLib: in CarbonLib 1.0 and later
1093
* Mac OS X: in version 10.0 and later
1095
function randomx(var x: double_t): double_t; external name '_randomx';
1098
{******************************************************************************
1099
* Relational operator *
1100
******************************************************************************}
1101
{ relational operator }
1116
* Non-Carbon CFM: in MathLib 1.0 and later
1117
* CarbonLib: in CarbonLib 1.0 and later
1118
* Mac OS X: in version 10.0 and later
1120
function relation(x: double_t; y: double_t): relop; external name '_relation';
1123
{*******************************************************************************
1125
* Binary to decimal conversions *
1127
* SIGDIGLEN Significant decimal digits. *
1129
* decimal A record which provides an intermediate unpacked form for *
1130
* programmers who wish to do their own parsing of numeric input *
1131
* or formatting of numeric output. *
1133
* decform Controls each conversion to a decimal string. The style field *
1134
* is either FLOATDECIMAL or FIXEDDECIMAL. If FLOATDECIMAL, the *
1135
* value of the field digits is the number of significant digits. *
1136
* If FIXEDDECIMAL value of the field digits is the number of *
1137
* digits to the right of the decimal point. *
1139
* num2dec Converts a double_t to a decimal record using a decform. *
1140
* dec2num Converts a decimal record d to a double_t value. *
1141
* dec2str Converts a decform and decimal to a string using a decform. *
1142
* str2dec Converts a string to a decimal struct. *
1143
* dec2d Similar to dec2num except a double is returned (68k only). *
1144
* dec2f Similar to dec2num except a float is returned. *
1145
* dec2s Similar to dec2num except a short is returned. *
1146
* dec2l Similar to dec2num except a long is returned. *
1148
*******************************************************************************}
1153
DecimalKindItem = (FLOATDECIMAL, FIXEDDECIMAL);
1154
DecimalKind = DecimalKindItem;
1157
sgn: 0..1; { sign 0 for +, 1 for - }
1171
* Non-Carbon CFM: in MathLib 1.0 and later
1172
* CarbonLib: in CarbonLib 1.0 and later
1173
* Mac OS X: in version 10.0 and later
1175
procedure num2dec(const (*var*) f: decform; x: double_t; var d: decimal); external name '_num2dec';
1181
* Non-Carbon CFM: in MathLib 1.0 and later
1182
* CarbonLib: in CarbonLib 1.0 and later
1183
* Mac OS X: in version 10.0 and later
1185
function dec2num(const (*var*) d: decimal): double_t; external name '_dec2num';
1191
* Non-Carbon CFM: in MathLib 1.0 and later
1192
* CarbonLib: in CarbonLib 1.0 and later
1193
* Mac OS X: in version 10.0 and later
1195
procedure dec2str(const (*var*) f: decform; const (*var*) d: decimal; s: CStringPtr); external name '_dec2str';
1201
* Non-Carbon CFM: in MathLib 1.0 and later
1202
* CarbonLib: in CarbonLib 1.0 and later
1203
* Mac OS X: in version 10.0 and later
1205
procedure str2dec(s: ConstCStringPtr; var ix: SInt16; var d: decimal; var vp: SInt16); external name '_str2dec';
1207
{$ifc TARGET_CPU_68K}
1208
{$ifc CALL_NOT_IN_CARBON}
1213
* Non-Carbon CFM: not available
1214
* CarbonLib: not available
1215
* Mac OS X: not available
1217
function dec2d(const (*var*) d: decimal): Double; external name '_dec2d';
1219
{$endc} {CALL_NOT_IN_CARBON}
1220
{$endc} {TARGET_CPU_68K}
1225
* Non-Carbon CFM: in MathLib 1.0 and later
1226
* CarbonLib: in CarbonLib 1.0 and later
1227
* Mac OS X: in version 10.0 and later
1229
function dec2f(const (*var*) d: decimal): Single; external name '_dec2f';
1235
* Non-Carbon CFM: in MathLib 1.0 and later
1236
* CarbonLib: in CarbonLib 1.0 and later
1237
* Mac OS X: in version 10.0 and later
1239
function dec2s(const (*var*) d: decimal): SInt16; external name '_dec2s';
1245
* Non-Carbon CFM: in MathLib 1.0 and later
1246
* CarbonLib: in CarbonLib 1.0 and later
1247
* Mac OS X: in version 10.0 and later
1249
function dec2l(const (*var*) d: decimal): SInt32; external name '_dec2l';
1252
{*******************************************************************************
1254
* 68k-only Transfer Function Prototypes *
1256
*******************************************************************************}
1257
{$ifc TARGET_CPU_68K}
1258
{$ifc CALL_NOT_IN_CARBON}
1263
* Non-Carbon CFM: not available
1264
* CarbonLib: not available
1265
* Mac OS X: not available
1267
procedure x96tox80(const (*var*) x: extended96; var x80: extended80); external name '_x96tox80';
1273
* Non-Carbon CFM: not available
1274
* CarbonLib: not available
1275
* Mac OS X: not available
1277
procedure x80tox96(const (*var*) x80: extended80; var x: extended96); external name '_x80tox96';
1279
{$endc} {CALL_NOT_IN_CARBON}
1280
{$endc} {TARGET_CPU_68K}
1282
{*******************************************************************************
1284
* PowerPC-only Function Prototypes *
1286
*******************************************************************************}
1288
{$ifc TARGET_CPU_PPC}
1294
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1295
* CarbonLib: in CarbonLib 1.0 and later
1296
* Mac OS X: not available
1298
function cosl(x: LongDouble): LongDouble; external name '_cosl';
1305
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1306
* CarbonLib: in CarbonLib 1.0 and later
1307
* Mac OS X: not available
1309
function sinl(x: LongDouble): LongDouble; external name '_sinl';
1316
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1317
* CarbonLib: in CarbonLib 1.0 and later
1318
* Mac OS X: not available
1320
function tanl(x: LongDouble): LongDouble; external name '_tanl';
1327
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1328
* CarbonLib: in CarbonLib 1.0 and later
1329
* Mac OS X: not available
1331
function acosl(x: LongDouble): LongDouble; external name '_acosl';
1338
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1339
* CarbonLib: in CarbonLib 1.0 and later
1340
* Mac OS X: not available
1342
function asinl(x: LongDouble): LongDouble; external name '_asinl';
1349
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1350
* CarbonLib: in CarbonLib 1.0 and later
1351
* Mac OS X: not available
1353
function atanl(x: LongDouble): LongDouble; external name '_atanl';
1360
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1361
* CarbonLib: in CarbonLib 1.0 and later
1362
* Mac OS X: not available
1364
function atan2l(y: LongDouble; x: LongDouble): LongDouble; external name '_atan2l';
1371
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1372
* CarbonLib: in CarbonLib 1.0 and later
1373
* Mac OS X: not available
1375
function coshl(x: LongDouble): LongDouble; external name '_coshl';
1382
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1383
* CarbonLib: in CarbonLib 1.0 and later
1384
* Mac OS X: not available
1386
function sinhl(x: LongDouble): LongDouble; external name '_sinhl';
1393
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1394
* CarbonLib: in CarbonLib 1.0 and later
1395
* Mac OS X: not available
1397
function tanhl(x: LongDouble): LongDouble; external name '_tanhl';
1404
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1405
* CarbonLib: in CarbonLib 1.0 and later
1406
* Mac OS X: not available
1408
function acoshl(x: LongDouble): LongDouble; external name '_acoshl';
1415
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1416
* CarbonLib: in CarbonLib 1.0 and later
1417
* Mac OS X: not available
1419
function asinhl(x: LongDouble): LongDouble; external name '_asinhl';
1426
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1427
* CarbonLib: in CarbonLib 1.0 and later
1428
* Mac OS X: not available
1430
function atanhl(x: LongDouble): LongDouble; external name '_atanhl';
1437
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1438
* CarbonLib: in CarbonLib 1.0 and later
1439
* Mac OS X: not available
1441
function expl(x: LongDouble): LongDouble; external name '_expl';
1448
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1449
* CarbonLib: in CarbonLib 1.0 and later
1450
* Mac OS X: not available
1452
function expm1l(x: LongDouble): LongDouble; external name '_expm1l';
1459
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1460
* CarbonLib: in CarbonLib 1.0 and later
1461
* Mac OS X: not available
1463
function exp2l(x: LongDouble): LongDouble; external name '_exp2l';
1470
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1471
* CarbonLib: in CarbonLib 1.0 and later
1472
* Mac OS X: not available
1474
function frexpl(x: LongDouble; var exponent: SInt32): LongDouble; external name '_frexpl';
1481
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1482
* CarbonLib: in CarbonLib 1.0 and later
1483
* Mac OS X: not available
1485
function ldexpl(x: LongDouble; n: SInt32): LongDouble; external name '_ldexpl';
1492
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1493
* CarbonLib: in CarbonLib 1.0 and later
1494
* Mac OS X: not available
1496
function logl(x: LongDouble): LongDouble; external name '_logl';
1503
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1504
* CarbonLib: in CarbonLib 1.0 and later
1505
* Mac OS X: not available
1507
function log1pl(x: LongDouble): LongDouble; external name '_log1pl';
1514
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1515
* CarbonLib: in CarbonLib 1.0 and later
1516
* Mac OS X: not available
1518
function log10l(x: LongDouble): LongDouble; external name '_log10l';
1525
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1526
* CarbonLib: in CarbonLib 1.0 and later
1527
* Mac OS X: not available
1529
function log2l(x: LongDouble): LongDouble; external name '_log2l';
1536
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1537
* CarbonLib: in CarbonLib 1.0 and later
1538
* Mac OS X: not available
1540
function logbl(x: LongDouble): LongDouble; external name '_logbl';
1547
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1548
* CarbonLib: in CarbonLib 1.0 and later
1549
* Mac OS X: not available
1551
function scalbl(x: LongDouble; n: SInt32): LongDouble; external name '_scalbl';
1558
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1559
* CarbonLib: in CarbonLib 1.0 and later
1560
* Mac OS X: not available
1562
function fabsl(x: LongDouble): LongDouble; external name '_fabsl';
1569
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1570
* CarbonLib: in CarbonLib 1.0 and later
1571
* Mac OS X: not available
1573
function hypotl(x: LongDouble; y: LongDouble): LongDouble; external name '_hypotl';
1580
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1581
* CarbonLib: in CarbonLib 1.0 and later
1582
* Mac OS X: not available
1584
function powl(x: LongDouble; y: LongDouble): LongDouble; external name '_powl';
1591
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1592
* CarbonLib: in CarbonLib 1.0 and later
1593
* Mac OS X: not available
1595
function sqrtl(x: LongDouble): LongDouble; external name '_sqrtl';
1602
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1603
* CarbonLib: in CarbonLib 1.0 and later
1604
* Mac OS X: not available
1606
function erfl(x: LongDouble): LongDouble; external name '_erfl';
1613
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1614
* CarbonLib: in CarbonLib 1.0 and later
1615
* Mac OS X: not available
1617
function erfcl(x: LongDouble): LongDouble; external name '_erfcl';
1624
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1625
* CarbonLib: in CarbonLib 1.0 and later
1626
* Mac OS X: not available
1628
function gammal(x: LongDouble): LongDouble; external name '_gammal';
1635
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1636
* CarbonLib: in CarbonLib 1.0 and later
1637
* Mac OS X: not available
1639
function lgammal(x: LongDouble): LongDouble; external name '_lgammal';
1646
* Non-Carbon CFM: in MathLib 2.0 and later or as macro/inline
1647
* CarbonLib: in CarbonLib 1.0 and later
1648
* Mac OS X: not available
1650
function ceill(x: LongDouble): LongDouble; external name '_ceill';
1657
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1658
* CarbonLib: in CarbonLib 1.0 and later
1659
* Mac OS X: not available
1661
function floorl(x: LongDouble): LongDouble; external name '_floorl';
1668
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1669
* CarbonLib: in CarbonLib 1.0 and later
1670
* Mac OS X: not available
1672
function rintl(x: LongDouble): LongDouble; external name '_rintl';
1679
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1680
* CarbonLib: in CarbonLib 1.0 and later
1681
* Mac OS X: not available
1683
function nearbyintl(x: LongDouble): LongDouble; external name '_nearbyintl';
1690
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1691
* CarbonLib: in CarbonLib 1.0 and later
1692
* Mac OS X: not available
1694
function rinttoll(x: LongDouble): SInt32; external name '_rinttoll';
1701
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1702
* CarbonLib: in CarbonLib 1.0 and later
1703
* Mac OS X: not available
1705
function roundl(x: LongDouble): LongDouble; external name '_roundl';
1712
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1713
* CarbonLib: in CarbonLib 1.0 and later
1714
* Mac OS X: not available
1716
function roundtoll(x: LongDouble): SInt32; external name '_roundtoll';
1723
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1724
* CarbonLib: in CarbonLib 1.0 and later
1725
* Mac OS X: not available
1727
function truncl(x: LongDouble): LongDouble; external name '_truncl';
1734
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1735
* CarbonLib: in CarbonLib 1.0 and later
1736
* Mac OS X: not available
1738
function remainderl(x: LongDouble; y: LongDouble): LongDouble; external name '_remainderl';
1745
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1746
* CarbonLib: in CarbonLib 1.0 and later
1747
* Mac OS X: not available
1749
function remquol(x: LongDouble; y: LongDouble; var quo: SInt32): LongDouble; external name '_remquol';
1756
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1757
* CarbonLib: in CarbonLib 1.0 and later
1758
* Mac OS X: not available
1760
function copysignl(x: LongDouble; y: LongDouble): LongDouble; external name '_copysignl';
1767
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1768
* CarbonLib: in CarbonLib 1.0 and later
1769
* Mac OS X: not available
1771
function fdiml(x: LongDouble; y: LongDouble): LongDouble; external name '_fdiml';
1778
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1779
* CarbonLib: in CarbonLib 1.0 and later
1780
* Mac OS X: not available
1782
function fmaxl(x: LongDouble; y: LongDouble): LongDouble; external name '_fmaxl';
1789
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1790
* CarbonLib: in CarbonLib 1.0 and later
1791
* Mac OS X: not available
1793
function fminl(x: LongDouble; y: LongDouble): LongDouble; external name '_fminl';
1795
{$ifc undefined __NOEXTENSIONS__}
1800
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1801
* CarbonLib: in CarbonLib 1.0 and later
1802
* Mac OS X: not available
1804
function relationl(x: LongDouble; y: LongDouble): relop; external name '_relationl';
1811
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1812
* CarbonLib: in CarbonLib 1.0 and later
1813
* Mac OS X: not available
1815
procedure num2decl(const (*var*) f: decform; x: LongDouble; var d: decimal); external name '_num2decl';
1822
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1823
* CarbonLib: in CarbonLib 1.0 and later
1824
* Mac OS X: not available
1826
function dec2numl(const (*var*) d: decimal): LongDouble; external name '_dec2numl';
1829
{$endc} {TARGET_CPU_PPC}
1830
{$endc} {TARGET_OS_MAC}
1832
{$ifc undefined __NOEXTENSIONS__}
1834
MathLib v2 has two new transfer functions: x80tod and dtox80. They can
1835
be used to directly transform 68k 80-bit extended data types to double
1836
and back for PowerPC based machines without using the functions
1837
x80told or ldtox80. Double rounding may occur.
1843
* Non-Carbon CFM: in MathLib 2.0 and later
1844
* CarbonLib: in CarbonLib 1.0 and later
1845
* Mac OS X: in version 10.0 and later
1847
function x80tod(const (*var*) x80: extended80): Double; external name '_x80tod';
1853
* Non-Carbon CFM: in MathLib 2.0 and later
1854
* CarbonLib: in CarbonLib 1.0 and later
1855
* Mac OS X: in version 10.0 and later
1857
procedure dtox80((*const*) var x: Double; var x80: extended80); external name '_dtox80';
1859
{$ifc TARGET_CPU_PPC}
1864
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1865
* CarbonLib: in CarbonLib 1.0 and later
1866
* Mac OS X: not available
1868
procedure x80told(const (*var*) x80: extended80; var x: LongDouble); external name '_x80told';
1875
* Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
1876
* CarbonLib: in CarbonLib 1.0 and later
1877
* Mac OS X: not available
1879
procedure ldtox80((*const*) var x: LongDouble; var x80: extended80); external name '_ldtox80';
1881
{$endc} {TARGET_CPU_PPC}