-
Notifications
You must be signed in to change notification settings - Fork 167
/
Copy pathdecwide_t.h
6311 lines (5180 loc) · 350 KB
/
decwide_t.h
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
///////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 1999 - 2024. //
// Distributed under the Boost Software License, //
// Version 1.0. (See accompanying file LICENSE_1_0.txt //
// or copy at http://www.boost.org/LICENSE_1_0.txt) //
///////////////////////////////////////////////////////////////////
// This work is also based on an earlier work:
// "Algorithm 910: A Portable C++ Multiple-Precision System for Special-Function Calculations",
// in ACM TOMS, {VOL 37, ISSUE 4, (February 2011)} (C) ACM, 2011. http://doi.acm.org/10.1145/1916461.1916469
// This file implements the class decwide_t and most of its
// basic functions including constructors, binary arithmetic
// operations, comparison operators, selected elementary
// functions and more.
#ifndef DECWIDE_T_2004_06_01_H // NOLINT(llvm-header-guard)
#define DECWIDE_T_2004_06_01_H
//#define WIDE_DECIMAL_DISABLE_IOSTREAM
//#define WIDE_DECIMAL_DISABLE_DYNAMIC_MEMORY_ALLOCATION
//#define WIDE_DECIMAL_DISABLE_CONSTRUCT_FROM_STRING
//#define WIDE_DECIMAL_DISABLE_CACHED_CONSTANTS
//#define WIDE_DECIMAL_DISABLE_USE_STD_FUNCTION
//#define WIDE_DECIMAL_NAMESPACE=something_unique // (best if done on the command line)
#include <math/wide_decimal/decwide_t_detail_ops.h>
#include <util/utility/util_baselexical_cast.h>
#include <cmath>
#include <cstddef>
#include <cstdlib>
#include <cstring>
#if !defined(WIDE_DECIMAL_DISABLE_USE_STD_FUNCTION)
#include <functional>
#endif
#include <limits>
#if !defined(WIDE_DECIMAL_DISABLE_IOSTREAM)
#include <iomanip>
#include <ios>
#include <iostream>
#endif
#if (!defined(WIDE_DECIMAL_DISABLE_CONSTRUCT_FROM_STRING) && !defined(WIDE_DECIMAL_DISABLE_IOSTREAM))
#include <string>
#endif
#if !defined(WIDE_DECIMAL_NAMESPACE_BEGIN)
#error WIDE_DECIMAL_NAMESPACE_BEGIN is not defined. Ensure that <decwide_t_detail_namespace.h> is properly included.
#endif
#if !defined(WIDE_DECIMAL_NAMESPACE_END)
#error WIDE_DECIMAL_NAMESPACE_END is not defined. Ensure that <decwide_t_detail_namespace.h> is properly included.
#endif
#if (defined(__GNUC__) && (defined(__RL78__) || defined(__riscv)))
namespace std { using ::ilogb; }
#endif
#if (defined(__GNUC__) && defined(__riscv))
namespace std { using ::lround; }
#endif
#if (defined(__GNUC__) && (defined(__arm__) || defined(__AVR__)))
namespace std { using ::strtold; }
#endif
WIDE_DECIMAL_NAMESPACE_BEGIN
#if(__cplusplus >= 201703L)
namespace math::wide_decimal {
#else
namespace math { namespace wide_decimal { // NOLINT(modernize-concat-nested-namespaces)
#endif
// Forward declarations of various decwide_t namespace functions.
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType>
constexpr auto zero() -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType>
constexpr auto one() -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType>
constexpr auto two() -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType>
constexpr auto half() -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
#if !defined(WIDE_DECIMAL_DISABLE_CACHED_CONSTANTS)
template<const std::int32_t ParamDigitsBaseTen,
typename LimbType = std::uint32_t,
typename AllocatorType = std::allocator<void>,
typename InternalFloatType = double,
typename ExponentType = std::int64_t,
typename FftFloatType = double>
#if !defined(WIDE_DECIMAL_DISABLE_USE_STD_FUNCTION)
auto pi(const std::function<void(const std::uint32_t)>& pfn_callback_to_report_digits10 = nullptr) -> const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>&;
#else
auto pi(void(*pfn_callback_to_report_digits10)(const std::uint32_t) = nullptr) -> const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>&;
#endif
#else
template<const std::int32_t ParamDigitsBaseTen,
typename LimbType = std::uint32_t,
typename AllocatorType = std::allocator<void>,
typename InternalFloatType = double,
typename ExponentType = std::int64_t,
typename FftFloatType = double>
#if !defined(WIDE_DECIMAL_DISABLE_USE_STD_FUNCTION)
auto pi(const std::function<void(const std::uint32_t)>& pfn_callback_to_report_digits10 = nullptr) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
#else
auto pi(void(*pfn_callback_to_report_digits10)(const std::uint32_t) = nullptr) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
#endif
#endif
#if !defined(WIDE_DECIMAL_DISABLE_CACHED_CONSTANTS)
template<const std::int32_t ParamDigitsBaseTen,
typename LimbType = std::uint32_t,
typename AllocatorType = std::allocator<void>,
typename InternalFloatType = double,
typename ExponentType = std::int64_t,
typename FftFloatType = double>
auto ln_two() -> const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>&;
#else
template<const std::int32_t ParamDigitsBaseTen,
typename LimbType = std::uint32_t,
typename AllocatorType = std::allocator<void>,
typename InternalFloatType = double,
typename ExponentType = std::int64_t,
typename FftFloatType = double>
auto ln_two() -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
#endif
template<const std::int32_t ParamDigitsBaseTen,
typename LimbType = std::uint32_t,
typename AllocatorType = std::allocator<void>,
typename InternalFloatType = double,
typename ExponentType = std::int64_t,
typename FftFloatType = double>
#if !defined(WIDE_DECIMAL_DISABLE_USE_STD_FUNCTION)
auto calc_pi(const std::function<void(const std::uint32_t)>& pfn_callback_to_report_digits10 = nullptr) -> typename std::enable_if<(ParamDigitsBaseTen > static_cast<std::int32_t>(INT8_C(51))), decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
#else
auto calc_pi(void(*pfn_callback_to_report_digits10)(const std::uint32_t) = nullptr) -> typename std::enable_if<(ParamDigitsBaseTen > static_cast<std::int32_t>(INT8_C(51))), decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
#endif
template<const std::int32_t ParamDigitsBaseTen,
typename LimbType = std::uint32_t,
typename AllocatorType = std::allocator<void>,
typename InternalFloatType = double,
typename ExponentType = std::int64_t,
typename FftFloatType = double>
#if !defined(WIDE_DECIMAL_DISABLE_USE_STD_FUNCTION)
auto calc_pi(const std::function<void(const std::uint32_t)>& pfn_callback_to_report_digits10 = nullptr) -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast<std::int32_t>(INT8_C(51))) && std::is_same<LimbType, std::uint8_t>::value), decwide_t<ParamDigitsBaseTen, std::uint8_t, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
#else
auto calc_pi(void(*pfn_callback_to_report_digits10)(const std::uint32_t) = nullptr) -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast<std::int32_t>(INT8_C(51))) && std::is_same<LimbType, std::uint8_t>::value), decwide_t<ParamDigitsBaseTen, std::uint8_t, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
#endif
template<const std::int32_t ParamDigitsBaseTen,
typename LimbType = std::uint32_t,
typename AllocatorType = std::allocator<void>,
typename InternalFloatType = double,
typename ExponentType = std::int64_t,
typename FftFloatType = double>
#if !defined(WIDE_DECIMAL_DISABLE_USE_STD_FUNCTION)
auto calc_pi(const std::function<void(const std::uint32_t)>& pfn_callback_to_report_digits10 = nullptr) -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast<std::int32_t>(INT8_C(51))) && std::is_same<LimbType, std::uint16_t>::value), decwide_t<ParamDigitsBaseTen, std::uint16_t, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
#else
auto calc_pi(void(*pfn_callback_to_report_digits10)(const std::uint32_t) = nullptr) -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast<std::int32_t>(INT8_C(51))) && std::is_same<LimbType, std::uint16_t>::value), decwide_t<ParamDigitsBaseTen, std::uint16_t, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
#endif
template<const std::int32_t ParamDigitsBaseTen,
typename LimbType = std::uint32_t,
typename AllocatorType = std::allocator<void>,
typename InternalFloatType = double,
typename ExponentType = std::int64_t,
typename FftFloatType = double>
#if !defined(WIDE_DECIMAL_DISABLE_USE_STD_FUNCTION)
auto calc_pi(const std::function<void(const std::uint32_t)>& pfn_callback_to_report_digits10 = nullptr) -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast<std::int32_t>(INT8_C(51))) && std::is_same<LimbType, std::uint32_t>::value), decwide_t<ParamDigitsBaseTen, std::uint32_t, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
#else
auto calc_pi(void(*pfn_callback_to_report_digits10)(const std::uint32_t) = nullptr) -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast<std::int32_t>(INT8_C(51))) && std::is_same<LimbType, std::uint32_t>::value), decwide_t<ParamDigitsBaseTen, std::uint16_t, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
#endif
template<const std::int32_t ParamDigitsBaseTen,
typename LimbType = std::uint32_t,
typename AllocatorType = std::allocator<void>,
typename InternalFloatType = double,
typename ExponentType = std::int64_t,
typename FftFloatType = double>
auto calc_ln_two() -> typename std::enable_if<(ParamDigitsBaseTen > static_cast<std::int32_t>(INT8_C(51))), decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen,
typename LimbType = std::uint32_t,
typename AllocatorType = std::allocator<void>,
typename InternalFloatType = double,
typename ExponentType = std::int64_t,
typename FftFloatType = double>
auto calc_ln_two() -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast<std::int32_t>(INT8_C(51))) && std::is_same<LimbType, std::uint8_t>::value), decwide_t<ParamDigitsBaseTen, std::uint8_t, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen,
typename LimbType = std::uint32_t,
typename AllocatorType = std::allocator<void>,
typename InternalFloatType = double,
typename ExponentType = std::int64_t,
typename FftFloatType = double>
auto calc_ln_two() -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast<std::int32_t>(INT8_C(51))) && std::is_same<LimbType, std::uint16_t>::value), decwide_t<ParamDigitsBaseTen, std::uint16_t, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen,
typename LimbType = std::uint32_t,
typename AllocatorType = std::allocator<void>,
typename InternalFloatType = double,
typename ExponentType = std::int64_t,
typename FftFloatType = double>
auto calc_ln_two() -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast<std::int32_t>(INT8_C(51))) && std::is_same<LimbType, std::uint32_t>::value), decwide_t<ParamDigitsBaseTen, std::uint32_t, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen,
typename LimbType = std::uint32_t,
typename AllocatorType = std::allocator<void>,
typename InternalFloatType = double,
typename ExponentType = std::int64_t,
typename FftFloatType = double>
auto calc_ln_ten_low_precision() -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast<std::int32_t>(INT8_C(51))) && std::is_same<LimbType, std::uint8_t>::value), decwide_t<ParamDigitsBaseTen, std::uint8_t, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen,
typename LimbType = std::uint32_t,
typename AllocatorType = std::allocator<void>,
typename InternalFloatType = double,
typename ExponentType = std::int64_t,
typename FftFloatType = double>
auto calc_ln_ten_low_precision() -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast<std::int32_t>(INT8_C(51))) && std::is_same<LimbType, std::uint16_t>::value), decwide_t<ParamDigitsBaseTen, std::uint16_t, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen,
typename LimbType = std::uint32_t,
typename AllocatorType = std::allocator<void>,
typename InternalFloatType = double,
typename ExponentType = std::int64_t,
typename FftFloatType = double>
auto calc_ln_ten_low_precision() -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast<std::int32_t>(INT8_C(51))) && std::is_same<LimbType, std::uint32_t>::value), decwide_t<ParamDigitsBaseTen, std::uint32_t, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto constexpr unsigned_long_long_max() -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto constexpr signed_long_long_min () -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto constexpr signed_long_long_max () -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto constexpr long_double_min () -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto constexpr long_double_max () -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto (isnan) (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& x) -> bool;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto (isfinite)(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& x) -> bool;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto (isinf) (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& x) -> bool;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto (signbit) (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& x) -> bool;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto fabs (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& x) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto abs (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& x) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto floor (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& x) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto ceil (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& x) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto ldexp (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& v,
int e) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto frexp (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& v,
int* expon) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto fmod (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& v1,
const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& v2) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto ilogb (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& x) -> typename decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>::exponent_type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto sqrt (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& x) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto cbrt (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& x) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto rootn (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& x, // NOLINT(misc-no-recursion)
std::int32_t p) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto rootn_inv(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& x,
std::int32_t p) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto log (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& x) -> typename std::enable_if<(ParamDigitsBaseTen > static_cast<std::int32_t>(INT8_C(51))), decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type; // NOLINT(misc-no-recursion)
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto log (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& x) -> typename std::enable_if<(ParamDigitsBaseTen <= static_cast<std::int32_t>(INT8_C(51))), decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type; // NOLINT(misc-no-recursion)
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto exp (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& x) -> typename std::enable_if<(ParamDigitsBaseTen > static_cast<std::int32_t>(INT32_C(2000))), decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto exp (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& x) -> typename std::enable_if<(ParamDigitsBaseTen <= static_cast<std::int32_t>(INT32_C(2000))), decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto sinh (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& x) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto cosh (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& x) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto tanh (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& x) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto pow (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& b, // NOLINT(misc-no-recursion)
std::int64_t p) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto pow (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& x,
const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& a) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
#if !defined(WIDE_DECIMAL_DISABLE_IOSTREAM)
template<typename char_type, typename traits_type,
const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto operator<<(std::basic_ostream<char_type, traits_type>& os, const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& f) -> std::basic_ostream<char_type, traits_type>&;
#if !defined(WIDE_DECIMAL_DISABLE_CONSTRUCT_FROM_STRING)
template<typename char_type, typename traits_type,
const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto operator>>(std::basic_istream<char_type, traits_type>& is, decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& f) -> std::basic_istream<char_type, traits_type>&;
#endif // !WIDE_DECIMAL_DISABLE_CONSTRUCT_FROM_STRING
#endif // !WIDE_DECIMAL_DISABLE_IOSTREAM
// Global unary operators of decwide_t reference.
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto operator+(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& self) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto operator-(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& self) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
// Global add/sub/mul/div of const decwide_t& with const decwide_t&.
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto operator+(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u, const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& v) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto operator-(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u, const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& v) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto operator*(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u, const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& v) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto operator/(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u, const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& v) -> decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>;
// Global add/sub/mul/div of const decwide_t& with all built-in types.
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename SignedIntegralType>
auto operator+(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
SignedIntegralType n) -> typename std::enable_if< std::is_integral<SignedIntegralType>::value
&& (!std::is_unsigned<SignedIntegralType>::value),
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename UnsignedIntegralType>
auto operator+(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
UnsignedIntegralType n) -> typename std::enable_if< std::is_integral<UnsignedIntegralType>::value
&& std::is_unsigned<UnsignedIntegralType>::value,
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename FloatingPointType>
auto operator+(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
FloatingPointType f) -> typename std::enable_if<std::is_floating_point<FloatingPointType>::value,
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename SignedIntegralType>
auto operator-(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
SignedIntegralType n) -> typename std::enable_if< std::is_integral<SignedIntegralType>::value
&& (!std::is_unsigned<SignedIntegralType>::value),
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename UnsignedIntegralType>
auto operator-(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
UnsignedIntegralType n) -> typename std::enable_if< std::is_integral<UnsignedIntegralType>::value
&& std::is_unsigned<UnsignedIntegralType>::value,
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename FloatingPointType>
auto operator-(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
FloatingPointType f) -> typename std::enable_if<std::is_floating_point<FloatingPointType>::value,
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename SignedIntegralType>
auto operator*(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
SignedIntegralType n) -> typename std::enable_if< std::is_integral<SignedIntegralType>::value
&& (!std::is_unsigned<SignedIntegralType>::value),
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename UnsignedIntegralType>
auto operator*(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
UnsignedIntegralType n) -> typename std::enable_if< std::is_integral<UnsignedIntegralType>::value
&& std::is_unsigned<UnsignedIntegralType>::value,
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename FloatingPointType>
auto operator*(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
FloatingPointType f) -> typename std::enable_if<std::is_floating_point<FloatingPointType>::value,
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename SignedIntegralType>
auto operator/(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
SignedIntegralType n) -> typename std::enable_if< std::is_integral<SignedIntegralType>::value
&& (!std::is_unsigned<SignedIntegralType>::value),
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename UnsignedIntegralType>
auto operator/(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
UnsignedIntegralType n) -> typename std::enable_if< std::is_integral<UnsignedIntegralType>::value
&& std::is_unsigned<UnsignedIntegralType>::value,
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename FloatingPointType>
auto operator/(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
FloatingPointType f) -> typename std::enable_if<std::is_floating_point<FloatingPointType>::value,
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
// Global add/sub/mul/div of all built-in types with const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>&.
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename SignedIntegralType>
auto operator+(SignedIntegralType n,
const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u) -> typename std::enable_if< std::is_integral<SignedIntegralType>::value
&& (!std::is_unsigned<SignedIntegralType>::value),
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename UnsignedIntegralType>
auto operator+(UnsignedIntegralType n,
const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u) -> typename std::enable_if< std::is_integral<UnsignedIntegralType>::value
&& std::is_unsigned<UnsignedIntegralType>::value,
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename FloatingPointType>
auto operator+(FloatingPointType f,
const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u) -> typename std::enable_if<std::is_floating_point<FloatingPointType>::value,
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename ArithmeticType>
auto operator-(ArithmeticType n,
const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u) -> typename std::enable_if<std::is_arithmetic<ArithmeticType>::value,
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename SignedIntegralType>
auto operator*(SignedIntegralType n,
const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u) -> typename std::enable_if< std::is_integral<SignedIntegralType>::value
&& (!std::is_unsigned<SignedIntegralType>::value),
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename UnsignedIntegralType>
auto operator*(UnsignedIntegralType n,
const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u) -> typename std::enable_if< std::is_integral<UnsignedIntegralType>::value
&& std::is_unsigned<UnsignedIntegralType>::value,
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename FloatingPointType>
auto operator*(FloatingPointType f,
const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u) -> typename std::enable_if<std::is_floating_point<FloatingPointType>::value,
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename ArithmeticType>
auto operator/(ArithmeticType n,
const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u) -> typename std::enable_if<std::is_arithmetic<ArithmeticType>::value,
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
// Global self add/sub/mul/div of decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& with all built-in types.
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename SignedIntegralType>
auto operator+=(decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
SignedIntegralType n) -> typename std::enable_if< std::is_integral<SignedIntegralType>::value
&& (!std::is_unsigned<SignedIntegralType>::value),
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename UnsignedIntegralType>
auto operator+=(decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
UnsignedIntegralType n) -> typename std::enable_if< std::is_integral<UnsignedIntegralType>::value
&& std::is_unsigned<UnsignedIntegralType>::value,
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename FloatingPointType>
auto operator+=(decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
FloatingPointType f) -> typename std::enable_if<std::is_floating_point<FloatingPointType>::value,
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename SignedIntegralType>
auto operator-=(decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
SignedIntegralType n) -> typename std::enable_if< std::is_integral<SignedIntegralType>::value
&& (!std::is_unsigned<SignedIntegralType>::value),
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename UnsignedIntegralType>
auto operator-=(decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
UnsignedIntegralType n) -> typename std::enable_if< std::is_integral<UnsignedIntegralType>::value
&& std::is_unsigned<UnsignedIntegralType>::value,
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename FloatingPointType>
auto operator-=(decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
FloatingPointType f) -> typename std::enable_if<std::is_floating_point<FloatingPointType>::value,
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename SignedIntegralType>
auto operator*=(decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
SignedIntegralType n) -> typename std::enable_if< std::is_integral<SignedIntegralType>::value
&& (!std::is_unsigned<SignedIntegralType>::value),
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename UnsignedIntegralType>
auto operator*=(decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
UnsignedIntegralType n) -> typename std::enable_if< std::is_integral<UnsignedIntegralType>::value
&& std::is_unsigned<UnsignedIntegralType>::value,
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename FloatingPointType>
auto operator*=(decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
FloatingPointType f) -> typename std::enable_if<std::is_floating_point<FloatingPointType>::value,
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename SignedIntegralType>
auto operator/=(decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
SignedIntegralType n) -> typename std::enable_if< std::is_integral<SignedIntegralType>::value
&& (!std::is_unsigned<SignedIntegralType>::value),
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename UnsignedIntegralType>
auto operator/=(decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
UnsignedIntegralType n) -> typename std::enable_if< std::is_integral<UnsignedIntegralType>::value
&& std::is_unsigned<UnsignedIntegralType>::value,
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename FloatingPointType>
auto operator/=(decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u,
FloatingPointType f) -> typename std::enable_if<std::is_floating_point<FloatingPointType>::value,
decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>>::type;
// Global comparison operators of const decwide_t& with const decwide_t&.
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto operator< (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u, const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& v) -> bool;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto operator<=(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u, const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& v) -> bool;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto operator==(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u, const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& v) -> bool;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto operator!=(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u, const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& v) -> bool;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto operator>=(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u, const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& v) -> bool;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto operator> (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u, const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& v) -> bool;
// Global comparison operators of const decwide_t& with all built-in types.
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename ArithmeticType> auto operator< (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u, const ArithmeticType& v) -> typename std::enable_if<std::is_arithmetic<ArithmeticType>::value, bool>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename ArithmeticType> auto operator<=(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u, const ArithmeticType& v) -> typename std::enable_if<std::is_arithmetic<ArithmeticType>::value, bool>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename ArithmeticType> auto operator==(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u, const ArithmeticType& v) -> typename std::enable_if<std::is_arithmetic<ArithmeticType>::value, bool>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename ArithmeticType> auto operator!=(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u, const ArithmeticType& v) -> typename std::enable_if<std::is_arithmetic<ArithmeticType>::value, bool>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename ArithmeticType> auto operator>=(const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u, const ArithmeticType& v) -> typename std::enable_if<std::is_arithmetic<ArithmeticType>::value, bool>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename ArithmeticType> auto operator> (const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& u, const ArithmeticType& v) -> typename std::enable_if<std::is_arithmetic<ArithmeticType>::value, bool>::type;
// Global comparison operators of all built-in types with const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>&.
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename ArithmeticType> auto operator< (ArithmeticType u, const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& v) -> typename std::enable_if<std::is_arithmetic<ArithmeticType>::value, bool>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename ArithmeticType> auto operator<=(ArithmeticType u, const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& v) -> typename std::enable_if<std::is_arithmetic<ArithmeticType>::value, bool>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename ArithmeticType> auto operator==(ArithmeticType u, const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& v) -> typename std::enable_if<std::is_arithmetic<ArithmeticType>::value, bool>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename ArithmeticType> auto operator!=(ArithmeticType u, const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& v) -> typename std::enable_if<std::is_arithmetic<ArithmeticType>::value, bool>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename ArithmeticType> auto operator>=(ArithmeticType u, const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& v) -> typename std::enable_if<std::is_arithmetic<ArithmeticType>::value, bool>::type;
template<const std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType, typename ArithmeticType> auto operator> (ArithmeticType u, const decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>& v) -> typename std::enable_if<std::is_arithmetic<ArithmeticType>::value, bool>::type;
template<const std::int32_t ParamDigitsBaseTen,
typename LimbType,
typename AllocatorType,
typename InternalFloatType,
typename ExponentType,
typename FftFloatType>
class decwide_t // NOLINT(clang-analyzer-optin.performance.Padding)
{
public:
using limb_type = LimbType;
using exponent_type = ExponentType;
using fft_float_type = FftFloatType;
using internal_float_type = InternalFloatType;
// Check the limb type.
static_assert(( std::is_same<std::uint8_t, limb_type>::value
|| std::is_same<std::uint16_t, limb_type>::value
|| std::is_same<std::uint32_t, limb_type>::value),
"Error: limb_type (template parameter LimbType) "
"must be one of uint8_t, uint16_t or uint32_t.");
// Check the exponent type.
static_assert(( std::is_same<std::int8_t, exponent_type>::value
|| std::is_same<std::int16_t, exponent_type>::value
|| std::is_same<std::int32_t, exponent_type>::value
|| std::is_same<std::int64_t, exponent_type>::value),
"Error: exponent_type (template parameter ExponentType) "
"must be one of int8_t, int16_t, int32_t or int64_t.");
// Define the decwide_t digits characteristics.
static constexpr std::int32_t decwide_t_digits10 = detail::decwide_t_helper<ParamDigitsBaseTen, LimbType>::digits10;
static constexpr std::int32_t decwide_t_digits = detail::decwide_t_helper<ParamDigitsBaseTen, LimbType>::digits;
static constexpr std::int32_t decwide_t_max_digits10 = detail::decwide_t_helper<ParamDigitsBaseTen, LimbType>::max_digits10;
static constexpr std::int32_t decwide_t_radix = detail::decwide_t_helper<ParamDigitsBaseTen, LimbType>::radix;
static constexpr std::int32_t decwide_t_elem_digits10 = detail::decwide_t_helper<ParamDigitsBaseTen, LimbType>::elem_digits10;
static constexpr std::int32_t decwide_t_elem_number = detail::decwide_t_helper<ParamDigitsBaseTen, LimbType>::elem_number;
static constexpr std::int32_t decwide_t_elem_mask = detail::decwide_t_helper<ParamDigitsBaseTen, LimbType>::elem_mask;
static constexpr std::int32_t decwide_t_elem_mask_half = detail::decwide_t_helper<ParamDigitsBaseTen, LimbType>::elem_mask_half;
static constexpr std::int32_t decwide_t_elem_mask_min1 = static_cast<std::int32_t>(decwide_t_elem_mask - static_cast<std::int32_t>(INT8_C(1)));
static constexpr std::int32_t decwide_t_elems_for_kara = static_cast<std::int32_t>(INT32_C( 112) + INT32_C(1));
static constexpr std::int32_t decwide_t_elems_for_fft = static_cast<std::int32_t>(INT32_C(1792) + INT32_C(1));
static constexpr exponent_type decwide_t_max_exp10 = static_cast<exponent_type>(UINTMAX_C(1) << static_cast<unsigned>(std::numeric_limits<exponent_type>::digits - (std::is_same<exponent_type, std::int64_t>::value ? 4 : (std::is_same<exponent_type, std::int32_t>::value ? 3 : (std::is_same<exponent_type, std::int16_t>::value ? 2 : 1)))));
static constexpr exponent_type decwide_t_min_exp10 = -static_cast<exponent_type>(decwide_t_max_exp10);
static constexpr exponent_type decwide_t_max_exp = decwide_t_max_exp10;
static constexpr exponent_type decwide_t_min_exp = decwide_t_min_exp10;
private:
#if (defined(_MSC_VER) && (_MSC_VER < 1920))
#else
static constexpr auto is_void_allocator() noexcept -> bool { return std::is_same<AllocatorType, void>::value; }
#endif
// Rebind the decwide_t allocator to the granularity of the LimbType.
using allocator_conditional_type =
#if (defined(_MSC_VER) && (_MSC_VER < 1920))
typename std::conditional<std::is_same<AllocatorType, void>::value,
#else
typename std::conditional<is_void_allocator(),
#endif
std::allocator<void>,
AllocatorType>::type;
public:
using allocator_type =
typename std::allocator_traits<allocator_conditional_type>::template rebind_alloc<limb_type>;
// Define the internal representation type of the data field
// of a decwide_t. This can be either a statically or dynamically
// allocated fixed-size array-like container depending on the
// nature of the allocator type being used.
using representation_type =
#if (defined(_MSC_VER) && (_MSC_VER < 1920))
typename std::conditional<std::is_same<AllocatorType, void>::value,
#else
typename std::conditional<is_void_allocator(),
#endif
detail::fixed_static_array <limb_type, static_cast<std::size_t>(decwide_t_elem_number)>,
detail::fixed_dynamic_array<limb_type, static_cast<std::size_t>(decwide_t_elem_number), allocator_type>>::type;
using double_limb_type =
typename std::conditional<std::is_same<limb_type, std::uint32_t>::value,
std::uint64_t,
typename std::conditional<std::is_same<limb_type, std::uint16_t>::value,
std::uint32_t,
std::uint16_t>::type>::type;
using signed_limb_type = typename std::make_signed<limb_type>::type;
using unsigned_exponent_type = typename std::make_unsigned<exponent_type>::type;
// TBD: Consider supporting more floating-point classes.
// In particular, support for NaN is already being
// partially used through the specialization of limits.
// When starting, maybe begin with FP-class NaN.
enum class fpclass_type // NOLINT(performance-enum-size)
{
decwide_t_finite
};
private:
#if !defined(WIDE_DECIMAL_DISABLE_CACHED_CONSTANTS)
// LCOV_EXCL_START
// Static data initializer
struct initializer
{
initializer() noexcept
{
static_cast<void>(decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>::my_value_pi());
static_cast<void>(decwide_t<ParamDigitsBaseTen, LimbType, AllocatorType, InternalFloatType, ExponentType, FftFloatType>::my_value_ln_two());
}
initializer(const initializer&) = delete;
initializer(initializer&&) = delete;
auto operator=(const initializer&) noexcept -> initializer& = delete;
auto operator=(initializer&&) noexcept -> initializer& = delete;
~initializer() noexcept = default;
auto do_nothing() const noexcept -> void
{
// Do nothing on purpose.
}
};
static const initializer my_initializer;
// LCOV_EXCL_STOP
#endif
#if !defined(WIDE_DECIMAL_DISABLE_IOSTREAM)
static auto wr_string(const decwide_t& x,
std::string& str, // NOLINT(google-runtime-references)
std::ios::fmtflags ostrm_flags,
std::streamsize ostrm_precision,
std::streamsize ostrm_width,
char ostrm_fill = ' ') -> void; // NOLINT(readability-function-cognitive-complexity,google-runtime-references)
#endif
public:
// Default constructor.
constexpr decwide_t() noexcept
: my_data (),
my_exp (static_cast<exponent_type>(INT8_C(0))),
my_neg (false),
my_fpclass (fpclass_type::decwide_t_finite),
my_prec_elem(decwide_t_elem_number) { }
// Constructors from built-in unsigned integral types.
template<typename UnsignedIntegralType,
typename std::enable_if<( std::is_integral<UnsignedIntegralType>::value
&& std::is_unsigned<UnsignedIntegralType>::value
&& (std::numeric_limits<UnsignedIntegralType>::digits <= std::numeric_limits<limb_type>::digits))>::type const* = nullptr>
constexpr decwide_t(const UnsignedIntegralType u) // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
: my_data (decwide_t_elem_number),
my_exp (static_cast<exponent_type>(INT8_C(0))),
my_neg (false),
my_fpclass (fpclass_type::decwide_t_finite),
my_prec_elem(decwide_t_elem_number)
{
const auto u_is_less_than_mask =
(static_cast<limb_type>(u) < static_cast<limb_type>(decwide_t_elem_mask));
using local_size_type = typename representation_type::size_type;
if(u_is_less_than_mask)
{
my_data[static_cast<local_size_type>(UINT8_C(0))] = static_cast<limb_type>(u);
}
else
{
my_data[static_cast<local_size_type>(UINT8_C(0))] = static_cast<limb_type>(u / static_cast<limb_type>(decwide_t_elem_mask));
my_data[static_cast<local_size_type>(UINT8_C(1))] = static_cast<limb_type>(u % static_cast<limb_type>(decwide_t_elem_mask));
my_exp = static_cast<exponent_type>(decwide_t_elem_digits10);
}
}
// Constructors from built-in unsigned integral types.
template<typename UnsignedIntegralType,
typename std::enable_if<( std::is_integral<UnsignedIntegralType>::value
&& std::is_unsigned<UnsignedIntegralType>::value
&& (std::numeric_limits<limb_type>::digits < std::numeric_limits<UnsignedIntegralType>::digits))>::type const* = nullptr>
decwide_t(const UnsignedIntegralType u) : my_data (), // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
my_exp (static_cast<exponent_type>(INT8_C(0))),
my_neg (false),
my_fpclass (fpclass_type::decwide_t_finite),
my_prec_elem(decwide_t_elem_number)
{
from_unsigned_long_long(u);
}
// Constructors from built-in signed integral types.
template<typename SignedIntegralType,
typename std::enable_if<( std::is_integral<SignedIntegralType>::value
&& std::is_signed <SignedIntegralType>::value)>::type const* = nullptr>
decwide_t(const SignedIntegralType n) : my_data (), // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
my_exp (static_cast<exponent_type>(INT8_C(0))),
my_neg (n < static_cast<signed long long>(INT8_C(0))), // NOLINT(google-runtime-int)
my_fpclass (fpclass_type::decwide_t_finite),
my_prec_elem(decwide_t_elem_number)
{
const auto u =
static_cast<unsigned long long> // NOLINT(google-runtime-int)
(
((!my_neg) ? static_cast<unsigned long long>(n) // NOLINT(google-runtime-int)
: detail::negate(static_cast<unsigned long long>(n))) // NOLINT(google-runtime-int)
);
from_unsigned_long_long(u);
}
// Constructors from built-in floating-point types.
template<typename FloatingPointType,
typename std::enable_if<std::is_floating_point<FloatingPointType>::value>::type const* = nullptr>
decwide_t(const FloatingPointType f) : my_data (), // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
my_exp (static_cast<exponent_type>(INT8_C(0))),
my_neg (false),
my_fpclass (fpclass_type::decwide_t_finite),
my_prec_elem(decwide_t_elem_number)
{
from_builtin_float_type(f);
}
#if !defined(WIDE_DECIMAL_DISABLE_CONSTRUCT_FROM_STRING)
// Constructors from character representations.
explicit decwide_t(const char* s) : my_data (),
my_exp (static_cast<exponent_type>(INT8_C(0))),
my_neg (false),
my_fpclass (fpclass_type::decwide_t_finite),
my_prec_elem(decwide_t_elem_number)
{
static_cast<void>(rd_string(s));
}
#endif // !WIDE_DECIMAL_DISABLE_CONSTRUCT_FROM_STRING
// Copy constructor.
constexpr decwide_t(const decwide_t& other) : my_data (other.my_data),
my_exp (other.my_exp),
my_neg (other.my_neg),
my_fpclass (other.my_fpclass),
my_prec_elem(other.my_prec_elem) { }
// Move constructor.
constexpr decwide_t(decwide_t&& other) noexcept : my_data (static_cast<representation_type&&>(other.my_data)),
my_exp (other.my_exp),
my_neg (other.my_neg),
my_fpclass (other.my_fpclass),
my_prec_elem(other.my_prec_elem) { }
// Constructor from floating-point class type, even though
// (at the moment) decwide_t instances can only be finite.
explicit constexpr decwide_t(fpclass_type) // NOLINT(hicpp-named-parameter,readability-named-parameter)
: my_data (),
my_exp (static_cast<exponent_type>(INT8_C(0))),
my_neg (false),
my_fpclass (fpclass_type::decwide_t_finite),
my_prec_elem(decwide_t_elem_number) { }
private:
// Constructor from mantissa and exponent.
explicit decwide_t(const internal_float_type mantissa,
const exponent_type exponent)
: my_data (),
my_exp (static_cast<exponent_type>(INT8_C(0))),
my_neg (false),
my_fpclass (fpclass_type::decwide_t_finite),
my_prec_elem(decwide_t_elem_number)
{
// Create a decwide_t from mantissa and exponent.
// This constructor is, in fact, intended to maintain
// the full precision of the internal_float_type.
constexpr auto delta_zero =
static_cast<internal_float_type>
(
(
(std::numeric_limits<internal_float_type>::min)()
* static_cast<internal_float_type>
(
static_cast<internal_float_type>(static_cast<unsigned>(UINT8_C(1)))
+ std::numeric_limits<internal_float_type>::epsilon()
)
)
);
using std::fabs;
const auto mantissa_is_iszero = (fabs(mantissa) < delta_zero);
if(mantissa_is_iszero)
{
my_data.fill(static_cast<limb_type>(UINT8_C(0))); // LCOV_EXCL_LINE
}
else
{
const auto b_neg = (mantissa < static_cast<InternalFloatType>(0));
internal_float_type d = ((!b_neg) ? mantissa : -mantissa);
exponent_type e = exponent;
{
// Scale the input mantissa to lie between 1 and 10.
constexpr auto f_ten = static_cast<internal_float_type>(static_cast<std::uint_fast8_t>(UINT8_C(10)));
constexpr auto f_one = static_cast<internal_float_type>(static_cast<std::uint_fast8_t>(UINT8_C(1)));
while(d > f_ten) { d /= f_ten; ++e; } // NOLINT(altera-id-dependent-backward-branch)
while(d < f_one) { d *= f_ten; --e; } // NOLINT(altera-id-dependent-backward-branch)
auto shift = static_cast<std::int32_t>(e % static_cast<std::int32_t>(decwide_t_elem_digits10));
while(static_cast<std::int32_t>(shift % decwide_t_elem_digits10) != static_cast<std::int32_t>(INT8_C(0))) // NOLINT(altera-id-dependent-backward-branch)
{
d *= f_ten;
--e;
--shift;
}
}
my_exp = e;
my_neg = b_neg;
constexpr auto digit_elem_whole =
static_cast<int>
(
std::numeric_limits<internal_float_type>::max_digits10
/ static_cast<int>(decwide_t_elem_digits10)
);
constexpr auto digit_elem_mod =
static_cast<int>
(
std::numeric_limits<internal_float_type>::max_digits10
% static_cast<int>(decwide_t_elem_digits10)
);
constexpr auto digit_loops = // NOLINT(altera-id-dependent-backward-branch)
static_cast<int>
(
digit_elem_whole
+ static_cast<int>
(
(digit_elem_mod != static_cast<int>(INT8_C(0)))
? static_cast<int>(INT8_C(1))
: static_cast<int>(INT8_C(0))
)
);
using local_size_type = typename representation_type::size_type;
local_size_type limb_index;
// Extract the mantissa's decimal digits.
for( limb_index = static_cast<local_size_type>(UINT8_C(0));
limb_index < static_cast<local_size_type>(digit_loops); // NOLINT(altera-id-dependent-backward-branch)
++limb_index)
{
const auto n = static_cast<limb_type>(d);
my_data[limb_index] = n;
d -= static_cast<internal_float_type>(n);
d *= static_cast<internal_float_type>(decwide_t_elem_mask);
}
std::fill(my_data.begin() + static_cast<std::ptrdiff_t>(limb_index),
my_data.end(),
static_cast<limb_type>(UINT8_C(0)));
}
}
public:
~decwide_t() = default;
// Assignment operator.
auto operator=(const decwide_t& other) -> decwide_t& // NOLINT(cert-oop54-cpp)
{
if(this != &other)
{
my_data = other.my_data;
my_exp = other.my_exp;
my_neg = other.my_neg;
my_fpclass = other.my_fpclass;
my_prec_elem = other.my_prec_elem;
}
return *this;
}
// Move assignment operator.
auto operator=(decwide_t&& other) noexcept -> decwide_t&
{
my_data = static_cast<representation_type&&>(other.my_data);
my_exp = other.my_exp;
my_neg = other.my_neg;
my_fpclass = other.my_fpclass;
my_prec_elem = other.my_prec_elem;
return *this;
}
WIDE_DECIMAL_NODISCARD auto representation() noexcept -> representation_type& { return my_data; }
WIDE_DECIMAL_NODISCARD auto representation() const noexcept -> const representation_type& { return my_data; }
WIDE_DECIMAL_NODISCARD auto crepresentation() const noexcept -> const representation_type& { return my_data; }
// Binary arithmetic operators.
auto operator+=(const decwide_t& v) -> decwide_t& // NOLINT(readability-function-cognitive-complexity)
{
// TBD: Eliminate the temporary storage array my_n_data_for_add_sub.
// TBD: Limit the length of add/sub to only those ranges needed,
// whereby propagate borrow/carry may be necessary as well.
if(iszero())
{
return operator=(v);
}
const auto prec_elems_for_add_sub =
static_cast<std::int32_t>
(
(std::min)(my_prec_elem, v.my_prec_elem)
);
// Get the offset for the add/sub operation.
const auto max_delta_exp =
static_cast<exponent_type>
(
static_cast<exponent_type>(prec_elems_for_add_sub) * decwide_t_elem_digits10
);
using local_unsigned_exponent_wrap_type = detail::unsigned_wrap<unsigned_exponent_type, exponent_type>;
const local_unsigned_exponent_wrap_type u_exp( my_exp);
const local_unsigned_exponent_wrap_type v_exp(v.my_exp);
const local_unsigned_exponent_wrap_type ofs_exp = (u_exp - v_exp);
// Check if the operation is out of range, requiring special handling.
if( v.iszero()
|| ( (!ofs_exp.get_is_neg())
&& (ofs_exp.get_value_unsigned() >= static_cast<unsigned_exponent_type>(max_delta_exp))))
{
// Result is *this unchanged since v is negligible compared to *this.
return *this;
}
if( ofs_exp.get_is_neg()
&& (ofs_exp.get_value_unsigned() >= static_cast<unsigned_exponent_type>(max_delta_exp)))
{
// Result is *this = v since *this is negligible compared to v.
return operator=(v);
}
// Do the add/sub operation.
const auto ofs =
static_cast<std::int32_t>
(
((!ofs_exp.get_is_neg()) ? +static_cast<std::int32_t>(ofs_exp.get_value_unsigned() / static_cast<unsigned_exponent_type>(decwide_t_elem_digits10))
: -static_cast<std::int32_t>(ofs_exp.get_value_unsigned() / static_cast<unsigned_exponent_type>(decwide_t_elem_digits10)))
);
#if !defined(WIDE_DECIMAL_DISABLE_DYNAMIC_MEMORY_ALLOCATION)
representation_type my_n_data_for_add_sub;
#endif
if(my_neg == v.my_neg)
{
auto carry = limb_type { };
// Add v to *this, where the data array of either *this or v
// might have to be treated with a positive, negative or zero offset.
// The result is stored in *this. The data are added one element
// at a time, each element with carry.
if(ofs >= static_cast<std::int32_t>(INT8_C(0)))
{
std::copy(v.my_data.cbegin(),
v.my_data.cend() - static_cast<std::ptrdiff_t>(ofs),
my_n_data_for_add_sub.begin() + static_cast<std::ptrdiff_t>(ofs));
std::fill(my_n_data_for_add_sub.begin(),
my_n_data_for_add_sub.begin() + static_cast<std::ptrdiff_t>(ofs),
static_cast<limb_type>(UINT8_C(0)));
using const_limb_pointer_type = typename std::add_const<limb_type*>::type;
// Addition.
carry = detail::eval_add_n(my_data.data(),
static_cast<const_limb_pointer_type>(my_data.data()),
static_cast<const_limb_pointer_type>(my_n_data_for_add_sub.data()),
prec_elems_for_add_sub);
}
else
{