This repository has been archived by the owner on Aug 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmp_real.pas
8794 lines (7708 loc) · 235 KB
/
mp_real.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit mp_real;
{Multi precision real floating point arithmetic routines}
interface
{$ifdef VirtualPascal}
{$X+} {needed for pchars/RESULT}
{$endif}
{$i STD.INC}
{$ifdef BIT16}
{$N+}
{$X+} {needed for pchars}
{$endif}
uses
BTypes, mp_types;
{$i mp_conf.inc}
(*************************************************************************
DESCRIPTION : Multi precision real floating point arithmetic routines
REQUIREMENTS : BP7, D2-D7/D9-D10/D12/D17-D18/D25S, FPC, VP, WDOSX
EXTERNAL DATA : (mp_types)
MEMORY USAGE : heap
DISPLAY MODE : ---
REFERENCES : [3] D.E. Knuth: The Art of computer programming, Volume 2,
Seminumerical Algorithms, 3rd ed., 1998
http://www-cs-faculty.stanford.edu/~knuth/taocp.html
[8] Marcel Martin: NX - Numerics library of multiprecision
numbers for Delphi and Free Pascal, 2006-2009
www.ellipsa.eu/public/nx/index.html
[22] LiDIA - A Library for Computational Number Theory, 2006,
LiDIA-Group, Technische Universit„t Darmstadt, Fachbereich Informatik
[27] T. Papanikolaou: libF - Eine lange Gleitpunktarithmetik,
Diplomarbeit 1995, available online from
http://www.cdc.informatik.tu-darmstadt.de/reports/reports/papa.diplom.ps.gz
[31] J. Arndt, Matters Computational. Ideas, algorithms, source code.
http://www.jjj.de/fxt/#fxtbook
[35] R.P. Brent, P. Zimmermann: Modern Computer Arithmetic, Cambridge University Press, 2010.
A preliminary version (V0.5.9, Oct. 2010) of the book is available from
http://maths-people.anu.edu.au/~brent/pd/mca-cup-0.5.9.pdf
or http://arxiv.org/abs/1004.4710 (V0.5.1)
[37] R.M. Corless, G.H. Gonnet, D.E.G. Hare, D.J. Jeffrey, D.E. Knuth,
On the Lambert W Function, Adv. Comput. Math., 5 (1996), pp. 329-359.
http://www.apmaths.uwo.ca/~rcorless/frames/PAPERS/LambertW/LambertW.ps or
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.33.3583
[38] F. Johansson, Efficient implementation of the Hardy-Ramanujan-Rademacher
formula, 2012. Available from http://arxiv.org/abs/1205.5991v1
[41] [HMF]: M. Abramowitz, I.A. Stegun. Handbook of Mathematical
Functions. New York, 1970, http://www.math.sfu.ca/~cbm/aands/
Version Date Author Modification
------- -------- ------- ------------------------------------------
0.0.01 01.11.07 W.Ehrhardt Basic type definitions, mpf_init etc
0.0.02 03.11.07 we mpf_todouble/extended, s_mpf_normalize, mpf_set_int
0.0.03 03.11.07 we s_mpf_normalizep, mpf_initp, mpf_mul, mpf_expt_int
0.0.04 03.11.07 we mpf_exch, mpf_inv, mpf_div, mpf_is0
0.0.05 04.11.07 we mpf_abs, mpf_chs, mpf_mul_2k, s_mpf_incexp
0.0.06 04.11.07 we mpf_add, mpf_sub, s_mpf_addsub
0.0.07 04.11.07 we removed .flags, fix mpf_abs, mpf_chs
0.0.08 04.11.07 we mpf_cmp_mag, mpf_initp2
0.0.09 05.11.07 we mpf_get_default_prec, mpf_sqrt
0.0.10 07.11.07 we mpf_cmp, mpf_noinit, arg checks
0.0.11 07.11.07 we s_mpf_normalize: stick bit and postnormalization
0.0.12 07.11.07 we mpf_set_ext
0.0.13 08.11.07 we mpf_chg_prec, mpf_checksum
0.0.14 08.11.07 we mpf_int, mpf_frac, mpf_trunc
0.0.15 09.11.07 we mpf_add/sub for a=0, skip final sqr in mpf_expt_int
0.0.16 10.11.07 we mpf_is1, mpf_is1a, special cases in mpf_mul/div
0.0.17 10.11.07 we bugfix mpf_div
0.0.18 10.11.07 we mpf_div_mpi, mpf_mul_mpi, mpf_set_mpi
0.0.19 10.11.07 we s_mpf_addsub changed to s_mpf_inc, mpf_add/sub_mpi
0.0.20 11.11.07 we mpf_add_ext, mpf_sub_ext, mpf_div_ext, mpf_mul_ext
0.0.21 11.11.07 we mpf_read_decimal, mpf_read_radix
0.0.22 12.11.07 we Fix memory leak(s) if MPC_HaltOnError is not defined
0.0.23 13.11.07 we mpf_is_ge, mpf_is_lt
0.0.24 14.11.07 we s_mpf_to10_n, mpf_decimal, mpf_adecimal
0.0.25 15.11.07 we mpf_initp_multi_p, mpf_initp[x], mpf_clear[x],
0.0.26 15.11.07 we mpf_set1, overflow check in mpf_sqr
0.0.27 16.11.07 we s_mpf_inc: allow @x=@y, s_mpf_incf
0.0.28 16.11.07 we mpf_exp, bugfix mpf_read_radix for '-.xxx'
0.0.29 16.11.07 we s_mpf_incexp with BASM
0.0.30 17.11.07 we mpf_ln, use b with working precision in mpf_exp
0.0.31 17.11.07 we mpf_expt, mpf_iexpt
0.0.32 18.11.07 we exponent overflow checks via s_mpf_incexp
0.0.33 19.11.07 we mpf_pi_chud, mpf_pi_machin. pi via mp_read_unsigned_bin,
0.0.34 20.11.07 we mpf_set_pip uses AddrPiBytes (pi table linked only if needed)
0.0.35 23.11.07 we mpf_set_pip2k, mpf_set_pi2k, mpf_arctan
0.0.36 25.11.07 we mpf_trig, mpf_cos, mpf_sin, mpf_tan
0.0.37 26.11.07 we s_mpf_inc1
0.0.38 26.11.07 we rounding in mpf_set_pip2k, mpf_pi_chud/mpf_pi_machin outsourced
0.0.39 26.11.07 we mpf_is_eq, mpf_is_gt, mpf_is_le, mpf_is_ne
0.0.40 26.11.07 we mpf_random, s_mpf_to10_n (case a=1, removed c10)
0.0.41 29.11.07 we s_mpf_abs, s_mpf_chs, mpf_mul_d/int, mpf_div_d/int
0.0.42 01.12.07 we s_mpf_is0
0.0.43 02.12.07 we s_mpf_is_neg, bugfix mpf_div
0.0.44 02.12.07 we s_mpf_mod_pi2k (used in mpf_trig)
0.0.45 09.12.07 we mp_float to mp_types, mpf_ln with mpf_div_d/int
0.0.46 09.12.07 we use mpf_copyp in mp_trig to set ps^ and pc^
0.0.47 09.12.07 we improve mpf_sub_ext for a=0
0.0.48 16.12.07 we mpf_todecimal_n, mpf_is_eq_rel
0.0.49 17.12.07 we mpf_tohex_n, mpf_read_hex, (s_)mpf_toradix_n
0.0.50 18.12.07 we used s_mpf_normalizep in some routines for mpf_chg_prec
0.0.51 18.12.07 we (mpf_is_eq_rel_n)
0.0.52 20.12.07 we mpf_reldev
0.0.53 21.12.07 we mpf_trig: bugfix -eps, sum series for cos - 1
0.0.54 21.12.07 we improved mpf_exp
1.4.00 01.01.08 we check a<>0 in mpf_ln, s_mpf_add1
1.4.01 01.01.08 we s_mpf_dec1, mpf_expm1, mpf_ln1p
1.4.02 02.01.08 we mpf_cosh, mpf_sinh, mpf_tanh, mpf_atanh
1.4.03 03.01.08 we mpf_acosh, mpf_acosh1p, mpf_asinh
1.4.04 03.01.08 we mpf_arctan2, mpf_arccos, mpf_arcsin
1.4.05 05.01.08 we s_mpf_toradix_n: fix if rounded res = radix^ndd
1.4.06 06.01.08 we s_mpf_agm, mpf_agm, mpf_ccell1, mpf_ccell12
1.4.07 10.01.08 we mpf_set_mpi2k, mpf_ccell12: increased working precision
1.5.00 16.01.08 we Fix rounding/overflow in s_mpf_toradix_n
1.5.01 16.01.08 we mpf_writeln, mpf_write_decimal/radix, mpf_output_decimal/radix
1.5.02 17.01.08 we s_mpf_ldx, s_mpf_is_le0, s_mpf_is_ge0
1.5.03 18.01.08 we mpf_cosh/sinh: don't calculate inverse if it is to small
1.5.04 19.01.08 we mpf_acosh/asinh = ln(2a) for large a, mpf_sinh small fix
1.5.05 20.01.08 we mpf_ccell2, s_mpf_ccell12, s_mpf_incf with add32_ovr
1.5.06 25.01.08 we _set_ptab_const, mpf_set_ln2/10 functions
1.5.07 25.01.08 we mpf_10expt, mpf_2expt, mpf_log10, mpf_log2
1.5.08 28.01.08 we s_mpf_ldx returns MaxLongint if overflow, fix mpf_ln
1.5.09 29.01.08 we abs(b)=1 in mpf_mul/div_int/d
1.5.10 30.01.08 we mpf_read_radix: removed readxp quick hack
1.5.11 31.01.08 we {$x+} for VP and D1
1.5.12 03.02.08 we bugfix s_mpf_agm (don't use c in loop)
1.6.00 11.06.08 we MPXRange.Create('mpf_chg_prec: newprec out of range');
1.7.00 23.08.08 we Avoid FPC222 warning in mpf_decimal
1.7.01 16.09.08 we Accept 'b' or 'B' in binary exponents
1.7.02 24.09.08 we string replaced by mp_string
1.9.00 02.12.08 we Uses BTypes: char8, pchar8
1.9.01 13.12.08 we mpf_sumalt
1.10.00 21.01.09 we changes related to (s)mp_divrem
1.10.01 21.02.09 we mpf_sinhcosh
1.10.02 23.02.09 we mpf_read_radix: changed evaluation of fraction part
1.10.03 24.02.09 we mpf_round
1.10.04 25.02.09 we s_mpf_ldx(0)=-MaxLongint, mpf_ln1p for a=0,
1.10.05 25.02.09 we s_mpf_numbpart, mpf_numbpart
1.10.06 25.02.09 we mpf_add_int, mpf_sub_int
1.10.07 27.02.09 we s_mpf_frac, mpf_trig_ex
1.11.00 23.03.09 we mpf_sumaltf
1.11.01 30.03.09 we removed redefinition of pByte
1.12.00 05.07.09 we D12 fixes in mpf_read_radix and s_mpf_toradix_n
1.13.00 14.08.09 we small improvements in (s_)mpf_numbpart
1.13.01 23.08.09 we mpf_squad
1.13.02 01.11.09 we New names: mpf_arccosh,mpf_arccosh1p,mpf_arcsinh,mpf_arctanh,mpf_exp10,mpf_exp2
1.13.03 01.11.09 we mpf_cot,mpf_csc,mpf_sec,mpf_coth,mpf_csch,mpf_sech
1.13.04 02.11.09 we mpf_arccot,mpf_arccotc,mpf_arccsc,mpf_arcsec,mpf_arccoth,mpf_arccsch,mpf_arcsech
1.13.05 02.11.09 we changed mpf_arccosh domain to a >= 1
1.13.06 16.11.09 we mpf_init[x], x=2..5
1.13.07 24.11.09 we mpf_arccotc calls mpf_arccot for a>0
1.13.08 24.11.09 we inv_func/func_inv with 32 guard bits
1.14.00 31.01.10 we mpf_sqrt1pm1
1.14.01 07.02.10 we mpf_logbase
1.14.02 09.02.10 we improved guard bits calculation in mpf_expt
1.14.03 09.02.10 we mpf_cmp_ext, mpf_cmp_mag_ext
1.15.00 05.05.10 we basic s_mpf_toradix_alt
1.15.01 06.05.10 we mpf_(a)decimal_alt, mpf_todecimal_alt, mpf_toradix_alt
1.15.02 07.05.10 we mpf_write_radix_alt, mpf_write_decimal_alt
1.15.03 07.05.10 we mpf_output_radix_alt, mpf_output_decimal_alt
1.15.04 08.05.10 we s_mpf_toradix_alt: k = ndd-e-1
1.15.05 08.05.10 we mpf_round: fix quirk if @b = @a.mantissa
1.15.07 09.05.10 we mpf_todouble, mpf_toextended: pre-check max values
1.15.08 13.05.10 we mp_fract_sep
1.15.09 13.05.10 we improved s_mpf_toradix_alt: use s_mp_toradix_n for fractional part
1.15.09 13.05.10 we mpf_set_default_decprec
1.15.10 14.05.10 we improved s_mpf_toradix_alt: faster removal of trailing zeros
1.15.11 15.05.10 we s_mpf_toradix_alt: use IsPow2_w
1.15.12 15.05.10 we s_mpf_toradix_alt: improved for radix<>2^n
1.16.00 12.06.10 we Corrected some exception strings
1.16.01 13.06.10 we mpf_set_exp1, mpf_set_exp1p
1.16.02 17.07.10 we mpf_expt1pm1, mpf_exptm1
1.18.00 17.02.11 we mpf_lambertw
1.18.01 23.06.11 we mpf_sinc
1.18.02 23.06.11 we mpf_hav. mpf_archav
1.18.03 24.06.11 we mpf_gd, mpf_arcgd
1.18.04 24.06.11 we improved mpf_tanh
1.18.05 24.06.11 we mpf_coshm1
1.19.00 12.11.11 we Avoid some warnings for MAXDigits=32000 with MP_32BIT
1.20.00 16.01.12 we mpf_set_ext removed absolute
1.20.01 16.01.12 we mpf_set_dbl
1.20.02 16.01.12 we EXT64: redirect mpf_set_ext, mpf_toextended
1.20.03 16.01.12 we LambertW approximation with double
1.20.04 12.02.12 we s_mpf_lnagm
1.20.05 13.02.12 we improved mpf_ln1p
1.21.00 30.05.12 we faster s_mpf_numbpart
1.21.01 16.07.12 we s_mpf_rint
1.24.00 15.12.12 we Some word types changed to longint
1.24.01 23.12.12 we Removed MPC_Old_EleFun function names
1.24.02 03.01.13 we s_mpf_normalize: Fix type of up to TNInt
1.25.00 23.01.13 we improved mpf_todouble/mpf_toextended
1.25.01 31.01.13 we mpf_vers
1.26.00 20.02.13 we mpf_set_ext for denormals
1.26.01 30.07.13 we mpf_exp10m1, mpf_exp2m1
1.26.02 31.07.13 we mpf_log10p1, mpf_log2p1
1.27.00 16.12.13 we mpf_hypot
1.27.01 09.02.14 we mpf_divr_ext
1.27.02 10.02.14 we mpf_sincos
1.27.03 11.02.14 we mpf_exp10i
1.27.04 13.02.14 we s_mpf_is_gt0
1.27.05 15.02.14 we mpf_nroot
1.30.00 16.08.14 we delete superfluous second s_mpf_ldx(a) in mpf_exp
1.32.00 09.04.15 we BIT16-compatibility functions mpf_adecimal, mpf_adecimal_alt
1.35.00 26.07.17 we From fdamsupp: mpf_arccosd, mpf_arccotcd, mpf_arccotd,
mpf_arcsind, mpf_arctand, mpf_cbrt, mpf_cosd,
mpf_cospi, mpf_cotd, mpf_deg2rad, mpf_rad2deg,
mpf_rem_2pi, mpf_sind, mpf_sinpi, mpf_tand, mpf_tanpi
1.35.01 27.07.17 we Temp. var with increased precision in mpf_cbrt
1.37.00 10.05.18 we mpf_cell1
1.37.01 10.05.18 we mpf_cell2
1.37.02 11.05.18 we mpf_ccell1, mpf_ccell12, mpf_ccell2 for |k| > 1
1.37.03 11.05.18 we improved mpf_cell2
1.38.00 25.06.18 we mpf_??_ext changed to mpf_??_dbl
1.38.01 26.06.18 we separate functionw for mpf_add/sub/mul/div_ext
1.38.02 27.06.18 we const PINC for default precision elevation,
1.38.03 28.06.18 we some manual precision adjustments
1.39.00 12.11.18 we fix copy/paste bug in mpf_sinhcosh
1.39.01 12.11.18 we Error MP_PRECISION in s_mpf_mod_pi2k instead of assert
1.39.02 16.11.18 we fix subtle bug for mpf_arctan2(y,0)
**************************************************************************)
(*-------------------------------------------------------------------------
(C) Copyright 2007-2018 Wolfgang Ehrhardt
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from
the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software in
a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
----------------------------------------------------------------------------*)
type
sumalt_term_func = function (k: longint; var num, den: longint): boolean;
{sumalt_term_func must be of type (-1)^k*x(k), x(k)=num(k)/den(k) > 0}
{result = false if x(k) cannot be evaluated, e.g. den > MaxLongint.}
sumalt_fterm_func = function (k: longint; var term: mp_float): boolean;
{sumalt_fterm_func must be of type (-1)^k*x(k), x(k) >= 0}
{result = false if x(k) cannot be evaluated}
procedure mpf_abs(const a: mp_float; var b: mp_float);
{-Absolute value, b = |a|}
procedure mpf_add(const a,b: mp_float; var c: mp_float);
{-Calculate c = a+b}
procedure mpf_add_dbl(const a: mp_float; b: double; var c: mp_float);
{-Calculate c = a+b}
procedure mpf_add_int(const a: mp_float; b: longint; var c: mp_float);
{-Calculate c = a+b}
procedure mpf_add_mpi(const a: mp_float; const b: mp_int; var c: mp_float);
{-Calculate c = a+b}
function mpf_adecimal(const a: mp_float; ndd: word): ansistring;
{-Convert to decimal scientific representation with ndd digits, max 65000 digits for 32+ bit}
function mpf_adecimal_alt(const a: mp_float; ndd: word): ansistring;
{-Convert to decimal alternative representation with ndd digits, max 65000 digits for 32+ bit}
procedure mpf_agm(const a,b: mp_float; var c: mp_float);
{-Calculate c = AGM(|a|,|b|)}
procedure mpf_arccos(const a: mp_float; var b: mp_float);
{-Calculate b = arccos(a), |a| <= 1}
procedure mpf_arccosd(const a: mp_float; var b: mp_float);
{-Calculate b = arccos(a), b in degrees}
procedure mpf_arccosh(const a: mp_float; var b: mp_float);
{-Calculate b = arccosh(a), a >= 1. Note: for a near 1 the function}
{ arccosh1p(a-1) should be used to reduce cancellation errors!}
procedure mpf_arccosh1p(const a: mp_float; var b: mp_float);
{-Calculate b = arccosh(1+a), a>=0}
procedure mpf_arccot(const a: mp_float; var b: mp_float);
{-Calculate the sign symmetric circular cotangent b = arccot(a) = arctan(1/a)}
procedure mpf_arccotc(const a: mp_float; var b: mp_float);
{-Calculate the continuous circular cotangent b = arccotc(a) = Pi/2 - arctan(a)}
procedure mpf_arccotcd(const a: mp_float; var b: mp_float);
{-Calculate b = arccotc(a), b in degrees}
procedure mpf_arccotd(const a: mp_float; var b: mp_float);
{-Calculate b = arccot(a), b in degrees}
procedure mpf_arccoth(const a: mp_float; var b: mp_float);
{-Calculate the inverse hyperbolic cotangent b = arccoth(a), |a| > 1}
procedure mpf_arccsc(const a: mp_float; var b: mp_float);
{-Calculate the inverse circular cosecant b = arccsc(a), |a| >= 1}
procedure mpf_arccsch(const a: mp_float; var b: mp_float);
{-Calculate the inverse hyperbolic cosecant b = arccsch(a)}
procedure mpf_arcgd(const a: mp_float; var b: mp_float);
{-Calculate the inverse Gudermannian function b = arcgd(a) = arcsinh(tan(a))}
procedure mpf_archav(const a: mp_float; var b: mp_float);
{-Calculate the inverse haversine b = archav(a) = 2*arcsin(sqrt(a))}
procedure mpf_arcsec(const a: mp_float; var b: mp_float);
{-Calculate the inverse circular secant b = arcsec(a), |a| >= 1}
procedure mpf_arcsech(const a: mp_float; var b: mp_float);
{-Calculate the inverse hyperbolic secant b = arcsech(a), 0 < a <= 1}
procedure mpf_arcsin(const a: mp_float; var b: mp_float);
{-Calculate b = arcsin(a), |a| <= 1}
procedure mpf_arcsind(const a: mp_float; var b: mp_float);
{-Calculate b = arcsin(a), b in degrees}
procedure mpf_arctan(const a: mp_float; var b: mp_float);
{-Calculate b = arctan(a)}
procedure mpf_arctan2(const y,x: mp_float; var a: mp_float);
{-Calculate a = arctan(y/x) with special treatment for zero x or y. a is}
{ the principal value of arg(x + i*y), i.e. -pi < arctan2(y,x) <= pi.}
procedure mpf_arctand(const a: mp_float; var b: mp_float);
{-Calculate b = arctan(a), b in degrees}
procedure mpf_arcsinh(const a: mp_float; var b: mp_float);
{-Calculate b = arcsinh(a)}
procedure mpf_arctanh(const a: mp_float; var b: mp_float);
{-Calculate b = arctanh(a), |a| < 1}
procedure mpf_cbrt(const a: mp_float; var b: mp_float);
{-Calculate b = a^(1/3) }
procedure mpf_cell1(const k: mp_float; var KK: mp_float);
{-Calculate the complete elliptic integral of the first kind KK := K(k), |k|<>1, real part if |k|>1}
procedure mpf_cell2(const k: mp_float; var EK: mp_float);
{-Calculate the complete elliptic integral of the 2nd kind EE := E(k), real part if |k|>1}
procedure mpf_ccell1(const k: mp_float; var CK: mp_float);
{-Complementary complete elliptic integral of the first kind CK = CK(k)}
{ with k<>0 using AGM algorithm, real part if k<-1}
procedure mpf_ccell12(const k: mp_float; var CK, CE: mp_float);
{-Complementary complete elliptic integrals of the 1st and 2nd kind using}
{ AGM algorithm; k<>0 and pCK <> pCE, with init checks, real parts of K'(k) if k<-1}
procedure mpf_ccell2(const k: mp_float; var CE: mp_float);
{-Complementary complete elliptic integral of the 2nd kind CE = CE(k)}
function mpf_checksum(const a: mp_float): longint;
{-Return a checksum for a, -1 if mp_error<>MP_OKAY, -2 if not initialized}
procedure mpf_chg_prec(var a: mp_float; newprec: longint);
{-Change bitprec of a to newprec}
procedure mpf_chs(const a: mp_float; var b: mp_float);
{-Change sign, b = -a}
procedure mpf_clear(var a: mp_float);
{-Clear an mp_float}
procedure mpf_clear2(var a,b: mp_float);
{-Clear 2 mp_floats}
procedure mpf_clear3(var a,b,c: mp_float);
{-Clear 3 mp_floats}
procedure mpf_clear4(var a,b,c,d: mp_float);
{-Clear 4 mp_floats}
procedure mpf_clear5(var a,b,c,d,e: mp_float);
{-Clear 5 mp_floats}
function mpf_cmp(const a,b: mp_float): integer;
{-Compare two mp_floats, return sign(a-b)}
function mpf_cmp_dbl(const a: mp_float; b: double): integer;
{-Compare a and b, return sign(a-b)}
function mpf_cmp_mag(const a,b: mp_float): integer;
{-Compare magnitude of two mp_floats, return sign(|a|-|b|)}
function mpf_cmp_mag_dbl(const a: mp_float; b: double): integer;
{-Compare magnitude of a and b, return sign(|a|-|b|)}
procedure mpf_copy(const a: mp_float; var b: mp_float);
{-Copy a to b with b.bitprec=a.bitprec}
procedure mpf_copyp(const a: mp_float; var b: mp_float);
{-Copy a to b, preserve b.bitprec}
procedure mpf_cos(const a: mp_float; var b: mp_float);
{-Calculate b = cos(a)}
procedure mpf_cosd(const a: mp_float; var b: mp_float);
{-Calculate b = cos(a), a in degrees}
procedure mpf_cospi(const a: mp_float; var b: mp_float);
{-Calculate b = cos(Pi*a)}
procedure mpf_cosh(const a: mp_float; var b: mp_float);
{-Calculate b = cosh(a), |a| < 2^31 * ln(2)}
procedure mpf_coshm1(const a: mp_float; var b: mp_float);
{-Calculate b = cosh(a)-1, |a| < 2^31 * ln(2); special version for small a}
procedure mpf_cot(const a: mp_float; var b: mp_float);
{-Calculate the circular cotangent b := cot(a), a mod Pi <> 0}
procedure mpf_cotd(const a: mp_float; var b: mp_float);
{-Calculate b = cot(a), a in degrees}
procedure mpf_coth(const a: mp_float; var b: mp_float);
{-Calculate the hyperbolic cotangent b = coth(a), a <> 0}
procedure mpf_csc(const a: mp_float; var b: mp_float);
{-Calculate the circular cosecant b = csc(a), a mod Pi <> 0}
procedure mpf_csch(const a: mp_float; var b: mp_float);
{-Calculate the hyperbolic cosecant b = csch(a), a <> 0}
function mpf_decimal(const a: mp_float; ndd: word): mp_string;
{-Convert to decimal scientific representation with ndd digits, max 255 chars}
function mpf_decimal_alt(const a: mp_float; ndd: word): mp_string;
{-Convert to decimal alternative representation with ndd digits, max 255 chars}
procedure mpf_deg2rad(const a: mp_float; var b: mp_float);
{-Convert a in degrees to b in radians}
procedure mpf_div(const a,b: mp_float; var c: mp_float);
{-Calculate c = a/b}
procedure mpf_div_d(const a: mp_float; b: mp_digit; var c: mp_float);
{-Calculate c = a/b}
procedure mpf_div_dbl(const a: mp_float; b: double; var c: mp_float);
{-Calculate c = a/b}
procedure mpf_div_int(const a: mp_float; b: longint; var c: mp_float);
{-Calculate c = a/b}
procedure mpf_div_mpi(const a: mp_float; const b: mp_int; var c: mp_float);
{-Calculate c = a/b}
procedure mpf_divr_dbl(a: double; const b: mp_float; var c: mp_float);
{-Calculate c = a/b}
procedure mpf_exch(var a,b: mp_float);
{-Exchange two mp_floats (including bitprec)}
procedure mpf_exp(const a: mp_float; var b: mp_float);
{-Calculate b = exp(a), a < 2^31 * ln(2)}
procedure mpf_exp10(const a: mp_float; var b: mp_float);
{-Calculate b = 10^a}
procedure mpf_exp10i(n: longint; var a: mp_float);
{-Calculate a = 10^n}
procedure mpf_exp10m1(const a: mp_float; var b: mp_float);
{-Calculate b = 10^a-1}
procedure mpf_exp2(const a: mp_float; var b: mp_float);
{-Calculate b = 2^a}
procedure mpf_exp2m1(const a: mp_float; var b: mp_float);
{-Calculate b = 2^a-1}
procedure mpf_expm1(const a: mp_float; var b: mp_float);
{-Calculate b = exp(a)-1, a < 2^31 * ln(2); special version for small a}
procedure mpf_expt(const a,b: mp_float; var c: mp_float);
{-Calculate c = a^b, a>0}
procedure mpf_expt1pm1(const a,b: mp_float; var c: mp_float);
{-Calculate c = (1+a)^b-1, a>-1}
procedure mpf_exptm1(const a,b: mp_float; var c: mp_float);
{-Calculate c = a^b-1, a>0}
procedure mpf_expt_int(const a: mp_float; b: longint; var c: mp_float);
{-Calculate c = a^b}
procedure mpf_frac(const a: mp_float; var b: mp_float);
{-Set b to the fractional part of a; frac(x)=x-int(x)}
procedure mpf_gd(const a: mp_float; var b: mp_float);
{-Calculate the Gudermannian function b = gd(a) = arctan(sinh(a))}
function mpf_get_default_prec: longint;
{-Return current default (bit) precision, initial=240}
procedure mpf_hav(const a: mp_float; var b: mp_float);
{-Calculate the haversine b = hav(a) = 0.5*(1 - cos(a))}
procedure mpf_hypot(const a,b: mp_float; var c: mp_float);
{-Calculate c = sqrt(a^2 + b^2)}
procedure mpf_iexpt(a: longint; const b: mp_float; var c: mp_float);
{-Calculate c = a^b, a>0}
procedure mpf_init(var a: mp_float);
{-Initialize an mp_float with default precision}
procedure mpf_init2(var a,b: mp_float);
{-Initialize two mp_floats with default precision}
procedure mpf_init3(var a,b,c: mp_float);
{-Initialize 3 mp_floats with default precision}
procedure mpf_init4(var a,b,c,d: mp_float);
{-Initialize 4 mp_floats with default precision}
procedure mpf_init5(var a,b,c,d,e: mp_float);
{-Initialize 5 mp_floats with default precision}
procedure mpf_initp(var a: mp_float; prec: longint);
{-Initialize an mp_float with bit precision prec}
procedure mpf_initp2(var a,b: mp_float; prec: longint);
{-Initialize two mp_floats with bit precision prec}
procedure mpf_initp3(var a,b,c: mp_float; prec: longint);
{-Initialize 3 mp_floats with bit precision prec}
procedure mpf_initp4(var a,b,c,d: mp_float; prec: longint);
{-Initialize 4 mp_floats with bit precision prec}
procedure mpf_initp5(var a,b,c,d,e: mp_float; prec: longint);
{-Initialize 5 mp_floats with bit precision prec}
procedure mpf_initp_multi_p(var pv: array of pmp_float; prec: longint);
{-Initialize with bit precision prec a list of mp_floats given as a pointer}
{ vector; on error the already initialized mp_floats will be cleared}
procedure mpf_int(const a: mp_float; var b: mp_float);
{-Set b to the integer part of a; i.e. is b rounded toward zero}
procedure mpf_inv(const a: mp_float; var b: mp_float);
{-Calculate b = 1/a}
function mpf_is0(const a: mp_float): boolean;
{-Return true if a=0}
function mpf_is1(const a: mp_float): boolean;
{-Return true if a=1}
function mpf_is1a(const a: mp_float): boolean;
{-Return true if abs(a)=1}
function mpf_is_eq(const a,b: mp_float): boolean;
{-Return a = b}
function mpf_is_eq_rel(const a,b: mp_float): boolean;
{-Check if |a-b| <= r*2^(1-b.bitprec); r=1 if b=0, r=|b| otherwise}
function mpf_is_ge(const a,b: mp_float): boolean;
{-Return a >= b}
function mpf_is_gt(const a,b: mp_float): boolean;
{-Return a > b}
function mpf_is_le(const a,b: mp_float): boolean;
{-Return a <= b}
function mpf_is_lt(const a,b: mp_float): boolean;
{-Return a < b}
function mpf_is_ne(const a,b: mp_float): boolean;
{-Return a <> b}
procedure mpf_lambertw(const a: mp_float; var b: mp_float);
{-Calculate b = LambertW(a); principal branch, a >= -1/e}
procedure mpf_ln(const a: mp_float; var b: mp_float);
{-Calculate b = ln(a), a>0}
procedure mpf_ln1p(const a: mp_float; var b: mp_float);
{-Calculate b = ln(1+a), a > -1; special version for small a}
procedure mpf_log10(const a: mp_float; var b: mp_float);
{-Calculate b = log10(a), a>0}
procedure mpf_log10p1(const a: mp_float; var b: mp_float);
{-Calculate b = log10(1+a), a > -1}
procedure mpf_log2(const a: mp_float; var b: mp_float);
{-Calculate b = log2(a), a>0}
procedure mpf_log2p1(const a: mp_float; var b: mp_float);
{-Calculate b = log2(1+a), a > -1}
procedure mpf_logbase(const b,x: mp_float; var y: mp_float);
{-Calculate y = base b logarithm of x}
procedure mpf_mul(const a,b: mp_float; var c: mp_float);
{-Calculate c = a*b}
procedure mpf_mul_2k(const a: mp_float; k: longint; var b: mp_float);
{-Calculate b = a*2^k}
procedure mpf_mul_d(const a: mp_float; b: mp_digit; var c: mp_float);
{-Multiply by a digit}
procedure mpf_mul_dbl(const a: mp_float; b: double; var c: mp_float);
{-Calculate c = a*b}
procedure mpf_mul_int(const a: mp_float; b: longint; var c: mp_float);
{-Multiply by a 32 bit integer}
procedure mpf_mul_mpi(const a: mp_float; const b: mp_int; var c: mp_float);
{-Calculate c = a*b}
function mpf_not_init(const a: mp_float): boolean;
{-Sanity check if a is initialized, does not catch all cases!}
procedure mpf_nroot(const a: mp_float; n: longint; var b: mp_float);
{-Calculate the nth root of a: b = a^(1/n); n<>0, a >= 0 if n is even}
procedure mpf_numbpart(n: longint; var p: mp_int);
{-Calculate the number of partitions of n with Hardy-Ramanujan-Rademacher formula}
procedure mpf_output_decimal(const a: mp_float; ndd: word);
{-Write an mp_float to output using decimal scientific representation, ndd>0}
{ is the total number of digits (including one digit before the '.')}
procedure mpf_output_decimal_alt(const a: mp_float; ndd: word);
{-Write an mp_float to output using decimal alternative representation, ndd>0 is}
{ the total number of digits, trailing '.' or '0' are suppressed. If a is too}
{ large or too small, scientific representation is used.}
procedure mpf_output_radix(const a: mp_float; radix,ndd: word);
{-Write an mp_float to output using radix scientific representation, ndd>0}
{ is the total number of digits (including one digit before the '.')}
procedure mpf_output_radix_alt(const a: mp_float; radix,ndd: word);
{-Write an mp_float to output using radix alternative representation, ndd>0 is}
{ the total number of digits, trailing '.' or '0' are suppressed. If a is too}
{ large or too small, scientific representation is used. NOTE: no radix prefix/suffix!}
procedure mpf_rad2deg(const a: mp_float; var b: mp_float);
{-Convert a in radians to b in degrees}
procedure mpf_random(var a: mp_float);
{-Set to a random number uniformly distributed in [0,1)}
procedure mpf_read_decimal(var a: mp_float; str: pchar8);
{-Read a from ASCII float decimal string. str may contain a single '.'}
{ The exponent part is @[+|-]nnn (e or E can replace @). Integer or }
{ fractional part must be present.}
procedure mpf_read_hex(var a: mp_float; str: pchar8);
{-Read a from ASCII float hexadecimal string. str may contain a single}
{ '.'. The exponent part is @[+|-]nnn (h or H can replace @). Integer }
{ or fractional part must be present.}
procedure mpf_read_radix(var a: mp_float; str: pchar8; radix: word);
{-Read a from an ASCII float radix string. str may contain a single '.'.}
{ The exponent part <xp> is @[+|-]nnn, b/B, e/E, or h/H can replace @ if}
{ radix in [2,10,16]. The integer <ip> or fractional part <fp> must be }
{ present, nnn must be decimal, ie general format is <ip>.<fp>*radix^<xp>.}
function mpf_reldev(const a,b: mp_float): double;
{-Return abs((a-b)/b)*2^b.bitprec, special if b=0, or a-b=0}
procedure mpf_rem_2pi(const a: mp_float; var b: mp_float);
{-Calculate b = a mod (2*Pi)}
procedure mpf_round(const a: mp_float; var b: mp_int);
{-Round an mp_float to nearest mp_int}
procedure mpf_sec(const a: mp_float; var b: mp_float);
{-Calculate the circular secant b = sec(a), a mod Pi <> Pi/2}
procedure mpf_sech(const a: mp_float; var b: mp_float);
{-Calculate the hyperbolic secant b = sech(a)}
procedure mpf_set0(var a: mp_float);
{-Set a=0, a.bitprec is preserved}
procedure mpf_set1(var a: mp_float);
{-Set a=1, a.bitprec is preserved}
procedure mpf_set_default_decprec(dprec: word);
{-Set default bit precision to dprec*log_2(10), i.e. dprec decimal digits}
procedure mpf_set_default_prec(prec: longint);
{-Set new default (bit) precision}
procedure mpf_set_exp1(var a: mp_float);
{-Set a to exp(1), preserve a.bitprec}
procedure mpf_set_exp1p(var a: mp_float; prec: longint);
{-Set a to exp(1) with bit precision prec}
procedure mpf_set_dbl(var a: mp_float; b: double);
{-Set a to a double. Error if b = NAN or INF}
procedure mpf_set_int(var a: mp_float; b: longint);
{-Set a to a longint}
procedure mpf_set_ln10(var a: mp_float);
{-Set a to ln(10), preserve a.bitprec}
procedure mpf_set_ln10p(var a: mp_float; prec: longint);
{-Set a to ln(10) with bit precision prec}
procedure mpf_set_ln10p2k(var a: mp_float; k,prec: longint);
{-Set a to ln(10)*2^k with bit precision prec}
procedure mpf_set_ln2(var a: mp_float);
{-Set a to ln(2), preserve a.bitprec}
procedure mpf_set_ln2p(var a: mp_float; prec: longint);
{-Set a to ln(2) with bit precision prec}
procedure mpf_set_ln2p2k(var a: mp_float; k,prec: longint);
{-Set a to ln(2)*2^k with bit precision prec}
procedure mpf_set_mpi(var a: mp_float; const b: mp_int);
{-Set a to an mp_int}
procedure mpf_set_mpi2k(var a: mp_float; const m: mp_int; e: longint);
{-Set a to m*2^e (build a from mantissa and exponent)}
procedure mpf_set_pi(var a: mp_float);
{-Set a to pi, preserve a.bitprec}
procedure mpf_set_pi2k(var a: mp_float; k: longint);
{-Set a to pi*2^k, preserve a.bitprec}
procedure mpf_set_pip(var a: mp_float; prec: longint);
{-Set a to pi with bit precision prec}
procedure mpf_set_pip2k(var a: mp_float; k,prec: longint);
{-Set a to pi*2^k with bit precision prec}
procedure mpf_sin(const a: mp_float; var b: mp_float);
{-Calculate b = sin(a)}
procedure mpf_sinc(const a: mp_float; var b: mp_float);
{-Calculate b = sin(a)/a}
procedure mpf_sincos(const a: mp_float; var b,c: mp_float);
{-Calculate b = sin(a), c = cos(a); @b<>@c}
procedure mpf_sind(const a: mp_float; var b: mp_float);
{-Calculate b = sin(a), a in degrees}
procedure mpf_sinh(const a: mp_float; var b: mp_float);
{-Calculate b = sinh(a), |a| < 2^31 * ln(2)}
procedure mpf_sinhcosh(const a: mp_float; var b,c: mp_float);
{-Calculate b = sinh(a), c = cosh(a); @b<>@c, |a| < 2^31 * ln(2)}
procedure mpf_sinpi(const a: mp_float; var b: mp_float);
{-Calculate b = sin(Pi*a)}
procedure mpf_sqr(const a: mp_float; var b: mp_float);
{-Calculate b = a*a}
procedure mpf_sqrt(const a: mp_float; var b: mp_float);
{-Calculate b = sqrt(a)}
procedure mpf_sqrt1pm1(const a: mp_float; var b: mp_float);
{-Calculate b = sqrt(1+a)-1 with increased accuracy for a near 0, a >= -1}
function mpf_squad(const a,b,c: mp_float; var x1,y1,x2,y2: mp_float): integer;
{-Solve the quadratic equation a*x^2 + b*x + c = 0. Result is the number}
{ of different solutions: 0 (if a=b=0), 1 (x1), or 2 (x1 and x2). If the}
{ result is = -2, x1 + i*y1 and x2 + i*y2 are the two complex solutions.}
{ x1,y1,x2,y2 should be different variables and not the same as a,b or c}
procedure mpf_sub(const a,b: mp_float; var c: mp_float);
{-Calculate c = a-b}
procedure mpf_sub_int(const a: mp_float; b: longint; var c: mp_float);
{-Calculate c = a-b}
procedure mpf_sub_dbl(const a: mp_float; b: double; var c: mp_float);
{-Calculate c = a-b}
procedure mpf_sub_mpi(const a: mp_float; const b: mp_int; var c: mp_float);
{-Calculate c = a-b}
procedure mpf_sumalt(term: sumalt_term_func; n: longint; var s: mp_float; var Err: integer);
{-Calculate s=sum(i=0..n, term(i)) of alternating series with sumalt algorithm.}
{ If n<4, n is adjusted to bitprec of s. Err<>0 if a term cannot be evaluated.}
procedure mpf_sumaltf(fterm: sumalt_fterm_func; n: longint; var s: mp_float; var Err: integer);
{-Calculate s=sum(i=0..n, term(i)) of alternating series with sumalt algorithm.}
{ If n<4, n is adjusted to bitprec of s. Err<>0 if a term cannot be evaluated.}
procedure mpf_tan(const a: mp_float; var b: mp_float);
{-Calculate b = tan(a)}
procedure mpf_tand(const a: mp_float; var b: mp_float);
{-Calculate b = tan(a), a in degrees}
procedure mpf_tanh(const a: mp_float; var b: mp_float);
{-Calculate b = tanh(a)}
procedure mpf_tanpi(const a: mp_float; var b: mp_float);
{-Return b := tan(Pi*a)}
procedure mpf_todecimal_alt(const a: mp_float; ndd: word; str: pchar8; maxlen: word);
{-Convert an mp_float to decimal alternative representation, ndd>0 is the total}
{ number of digits, trailing '.' or '0' are suppressed. If a is too large or}
{ too small, scientific representation is used.}
procedure mpf_todecimal_n(const a: mp_float; ndd: word; str: pchar8; maxlen: word);
{-Convert an mp_float to decimal scientific representation, ndd>0 is the}
{ total number of digits (including one digit before the '.')}
function mpf_todouble(const a: mp_float): double;
{-Convert a to double, +-inf if too large}
procedure mpf_tohex_n(const a: mp_float; ndd: word; str: pchar8; maxlen: word);
{-Convert an mp_float to hexadecimal scientific representation, ndd>0 is the}
{ total number of digits (including one digit before the '.')}
procedure mpf_toradix_alt(const a: mp_float; radix, ndd: word; str: pchar8; maxlen: longint);
{-Convert an mp_float to radix alternative representation, ndd>0 is the total}
{ number of digits, trailing '.' or '0' are suppressed. If a is too large or}
{ too small, scientific representation is used. NOTE: no radix prefix/suffix!}
procedure mpf_toradix_n(const a: mp_float; radix, ndd: word; str: pchar8; maxlen: longint);
{-Convert an mp_float to radix scientific representation, ndd>0 is the}
{ total number of digits (including one digit before the '.')}
procedure mpf_trig(const a: mp_float; pc,ps,pt: pmp_float);
{-Calculate pc^=cos(a), ps^=sin(a), pt^=tan(a) if pointers are <> nil}
procedure mpf_trig_ex(const a: mp_float; mulpi: boolean; pc,ps,pt: pmp_float);
{-Calculate pc^=cos(a), ps^=sin(a), pt^=tan(a) if pointers are <> nil.}
{ If mulpi, calculate pc^=cos(a*Pi), ps^=sin(a*Pi), pt^=tan(a*Pi).}
procedure mpf_trunc(const a: mp_float; var b: mp_int);
{-Truncate mp_float to mp_int}
procedure mpf_vers(const a: mp_float; var b: mp_float);
{-Calculate the versine b = vers(a) = 1-cos(a)}
procedure mpf_writeln(const msg: mp_string; const a: mp_float; ndd: word);
{-Writeln a to output with leading msg}
procedure mpf_write_decimal(var tf: system.text; const a: mp_float; ndd: word);
{-Write an mp_float to file tf using decimal scientific representation, ndd>0}
{ is the total number of digits (including one digit before the '.')}
procedure mpf_write_decimal_alt(var tf: system.text; const a: mp_float; ndd: word);
{-Write an mp_float to file tf using decimal alternative representation, ndd>0 is}
{ the total number of digits, trailing '.' or '0' are suppressed. If a is too}
{ large or too small, scientific representation is used.}
procedure mpf_write_radix(var tf: system.text; const a: mp_float; radix,ndd: word);
{-Write an mp_float to file tf using radix scientific representation, ndd>0}
{ is the total number of digits (including one digit before the '.')}
procedure mpf_write_radix_alt(var tf: system.text; const a: mp_float; radix,ndd: word);
{-Write an mp_float to file tf using radix alternative representation, ndd>0 is}
{ the total number of digits, trailing '.' or '0' are suppressed. If a is too}
{ large or too small, scientific representation is used. NOTE: no radix prefix/suffix!}
{$ifndef EXT64}
procedure mpf_set_ext(var a: mp_float; x: extended);
{-Set a to an extended. Error if x = NAN or INF}
function mpf_toextended(const a: mp_float): extended;
{-Convert a to extended, +-inf if too large}
procedure mpf_add_ext(const a: mp_float; b: extended; var c: mp_float);
{-Calculate c = a+b}
procedure mpf_sub_ext(const a: mp_float; b: extended; var c: mp_float);
{-Calculate c = a-b}
procedure mpf_mul_ext(const a: mp_float; b: extended; var c: mp_float);
{-Calculate c = a*b}
procedure mpf_div_ext(const a: mp_float; b: extended; var c: mp_float);
{-Calculate c = a/b}
procedure mpf_divr_ext(a: extended; const b: mp_float; var c: mp_float);
{-Calculate c = a/b}
{$endif}
{#Z+}
{---------------------------------------------------------------------------}
{- 'Internal' functions, don't use them unless you know what you are doing -}
{---------------------------------------------------------------------------}
{#Z-}
procedure s_mpf_abs(var a: mp_float);
{-Absolute value of an mp_float, no init check}
procedure s_mpf_add1(const a: mp_float; var b: mp_float);
{-Calculate b = a+1; no init checks}
procedure s_mpf_agm(const a,b: mp_float; var c: mp_float; ps: pmp_float);
{-Calculate c = AGM(|a|,|b|), if ps<>nil set ps^=sum(2^k*c_k^2); ps<>@c, no init check}
procedure s_mpf_ccell12(const k: mp_float; pCK, pCE: pmp_float);
{-Complementary complete elliptic integrals of the 1st and 2nd kind using}
{ AGM algorithm; k<>0 and pCK <> pCE, with init checks, real parts of K'(k) if k<-1}
procedure s_mpf_chs(var a: mp_float);
{-Change sign of an mp_float, no init check}
function s_mpf_cmp_mag(const a,b: mp_float): integer;
{-Compare magnitude of two mp_floats, return sign(|a|-|b|), no init check}
procedure s_mpf_dec1(var a: mp_float);
{-Calculate a = a-1; no init check}
procedure s_mpf_inc(var x: mp_float; const y: mp_float);
{-Calculate x = x+y}
procedure s_mpf_frac(const a: mp_float; var b: mp_float; podd: pBoolean);
{-Set b to the fractional part of a; frac(x)=x-int(x), if podd<>nil set podd^=odd(trunc(a))}
function s_mpf_incf(var x: mp_float; const y: mp_float): boolean;
{-Calculate x = x+y; return true if x is changed}
procedure s_mpf_incexp(var a: mp_float; x: longint);
{-Increment a.exponent by x, do nothing if a.mantissa=0}
procedure s_mpf_inc1(var a: mp_float);
{-Calculate a = a+1; no init check}
function s_mpf_is_ge0(const a: mp_float): boolean;
{-Return true if a>=0, no init checks}
function s_mpf_is_gt0(const a: mp_float): boolean;
{-Return true if a>0, no init checks}
function s_mpf_is_le0(const a: mp_float): boolean;
{-Return true if a<=0, no init checks}