1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.math4.core.jdkmath;
18
19 import java.util.function.IntUnaryOperator;
20 import java.util.function.IntBinaryOperator;
21 import java.util.function.LongUnaryOperator;
22 import java.util.function.LongBinaryOperator;
23 import java.util.function.DoubleUnaryOperator;
24 import java.util.function.DoubleBinaryOperator;
25 import java.util.function.DoubleToLongFunction;
26 import java.util.function.DoubleToIntFunction;
27 import java.util.function.LongToIntFunction;
28 import java.util.function.DoubleSupplier;
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 public final class JdkMath {
53
54 public static final double PI;
55
56 public static final double E;
57
58 private static final String PROPERTY_KEY = "org.apache.commons.math.jdkmath";
59
60 private static final IntUnaryOperator ABS_INT;
61
62 private static final LongUnaryOperator ABS_LONG;
63
64 private static final FloatUnaryOperator ABS_FLOAT;
65
66 private static final DoubleUnaryOperator ABS_DOUBLE;
67
68 private static final DoubleUnaryOperator ACOS;
69
70 private static final DoubleUnaryOperator ACOSH;
71
72 private static final IntBinaryOperator ADDEXACT_INT;
73
74 private static final LongBinaryOperator ADDEXACT_LONG;
75
76 private static final DoubleUnaryOperator ASIN;
77
78 private static final DoubleUnaryOperator ASINH;
79
80 private static final DoubleUnaryOperator ATAN;
81
82 private static final DoubleBinaryOperator ATAN2;
83
84 private static final DoubleUnaryOperator ATANH;
85
86 private static final DoubleUnaryOperator CBRT;
87
88 private static final DoubleUnaryOperator CEIL;
89
90 private static final FloatBinaryOperator COPYSIGN_FLOAT;
91
92 private static final DoubleBinaryOperator COPYSIGN_DOUBLE;
93
94 private static final DoubleUnaryOperator COS;
95
96 private static final DoubleUnaryOperator COSH;
97
98 private static final IntUnaryOperator DECREMENTEXACT_INT;
99
100 private static final LongUnaryOperator DECREMENTEXACT_LONG;
101
102 private static final DoubleUnaryOperator EXP;
103
104 private static final DoubleUnaryOperator EXPM1;
105
106 private static final DoubleUnaryOperator FLOOR;
107
108 private static final IntBinaryOperator FLOORDIV_INT;
109
110 private static final LongBinaryOperator FLOORDIV_LONG;
111
112 private static final IntBinaryOperator FLOORMOD_INT;
113
114 private static final LongBinaryOperator FLOORMOD_LONG;
115
116 private static final FloatToIntFunction GETEXPONENT_FLOAT;
117
118 private static final DoubleToIntFunction GETEXPONENT_DOUBLE;
119
120 private static final DoubleBinaryOperator HYPOT;
121
122 private static final DoubleBinaryOperator IEEEREMAINDER;
123
124 private static final IntUnaryOperator INCREMENTEXACT_INT;
125
126 private static final LongUnaryOperator INCREMENTEXACT_LONG;
127
128 private static final DoubleUnaryOperator LOG;
129
130 private static final DoubleUnaryOperator LOG10;
131
132 private static final DoubleUnaryOperator LOG1P;
133
134 private static final IntBinaryOperator MAX_INT;
135
136 private static final LongBinaryOperator MAX_LONG;
137
138 private static final FloatBinaryOperator MAX_FLOAT;
139
140 private static final DoubleBinaryOperator MAX_DOUBLE;
141
142 private static final IntBinaryOperator MIN_INT;
143
144 private static final LongBinaryOperator MIN_LONG;
145
146 private static final FloatBinaryOperator MIN_FLOAT;
147
148 private static final DoubleBinaryOperator MIN_DOUBLE;
149
150 private static final IntBinaryOperator MULTIPLYEXACT_INT;
151
152 private static final LongBinaryOperator MULTIPLYEXACT_LONG;
153
154 private static final IntUnaryOperator NEGATEEXACT_INT;
155
156 private static final LongUnaryOperator NEGATEEXACT_LONG;
157
158 private static final FloatDouble2FloatOperator NEXTAFTER_FLOAT;
159
160 private static final DoubleBinaryOperator NEXTAFTER_DOUBLE;
161
162 private static final FloatUnaryOperator NEXTDOWN_FLOAT;
163
164 private static final DoubleUnaryOperator NEXTDOWN_DOUBLE;
165
166 private static final FloatUnaryOperator NEXTUP_FLOAT;
167
168 private static final DoubleUnaryOperator NEXTUP_DOUBLE;
169
170 private static final DoubleBinaryOperator POW;
171
172 private static final DoubleSupplier RANDOM;
173
174 private static final DoubleUnaryOperator RINT;
175
176 private static final DoubleToLongFunction ROUND_DOUBLE;
177
178 private static final FloatToIntFunction ROUND_FLOAT;
179
180 private static final DoubleInt2DoubleOperator SCALB_DOUBLE;
181
182 private static final FloatInt2FloatOperator SCALB_FLOAT;
183
184 private static final FloatUnaryOperator SIGNUM_FLOAT;
185
186 private static final DoubleUnaryOperator SIGNUM_DOUBLE;
187
188 private static final DoubleUnaryOperator SIN;
189
190 private static final DoubleUnaryOperator SINH;
191
192 private static final DoubleUnaryOperator SQRT;
193
194 private static final IntBinaryOperator SUBTRACTEXACT_INT;
195
196 private static final LongBinaryOperator SUBTRACTEXACT_LONG;
197
198 private static final DoubleUnaryOperator TAN;
199
200 private static final DoubleUnaryOperator TANH;
201
202 private static final DoubleUnaryOperator TODEGREES;
203
204 private static final LongToIntFunction TOINTEXACT;
205
206 private static final DoubleUnaryOperator TORADIANS;
207
208 private static final DoubleUnaryOperator ULP_DOUBLE;
209
210 private static final FloatUnaryOperator ULP_FLOAT;
211
212
213 public enum Impl {
214
215 CM,
216
217 JDK
218 }
219
220 static {
221 final String prop = System.getProperty(PROPERTY_KEY);
222 final Impl impl = prop != null ?
223 Impl.valueOf(prop) :
224 Impl.CM;
225
226
227 switch (impl) {
228 case CM:
229 PI = AccurateMath.PI;
230 E = AccurateMath.E;
231 ABS_INT = AccurateMath::abs;
232 ABS_LONG = AccurateMath::abs;
233 ABS_FLOAT = AccurateMath::abs;
234 ABS_DOUBLE = AccurateMath::abs;
235 ACOS = AccurateMath::acos;
236 ACOSH = AccurateMath::acosh;
237 ADDEXACT_INT = AccurateMath::addExact;
238 ADDEXACT_LONG = AccurateMath::addExact;
239 ASIN = AccurateMath::asin;
240 ASINH = AccurateMath::asinh;
241 ATAN = AccurateMath::atan;
242 ATAN2 = AccurateMath::atan2;
243 ATANH = AccurateMath::atanh;
244 CBRT = AccurateMath::cbrt;
245 CEIL = AccurateMath::ceil;
246 COPYSIGN_FLOAT = AccurateMath::copySign;
247 COPYSIGN_DOUBLE = AccurateMath::copySign;
248 COS = AccurateMath::cos;
249 COSH = AccurateMath::cosh;
250 DECREMENTEXACT_INT = AccurateMath::decrementExact;
251 DECREMENTEXACT_LONG = AccurateMath::decrementExact;
252 EXP = AccurateMath::exp;
253 EXPM1 = AccurateMath::expm1;
254 FLOOR = AccurateMath::floor;
255 FLOORDIV_INT = AccurateMath::floorDiv;
256 FLOORDIV_LONG = AccurateMath::floorDiv;
257 FLOORMOD_INT = AccurateMath::floorMod;
258 FLOORMOD_LONG = AccurateMath::floorMod;
259 GETEXPONENT_FLOAT = AccurateMath::getExponent;
260 GETEXPONENT_DOUBLE = AccurateMath::getExponent;
261 HYPOT = AccurateMath::hypot;
262 IEEEREMAINDER = AccurateMath::IEEEremainder;
263 INCREMENTEXACT_INT = AccurateMath::incrementExact;
264 INCREMENTEXACT_LONG = AccurateMath::incrementExact;
265 LOG = AccurateMath::log;
266 LOG10 = AccurateMath::log10;
267 LOG1P = AccurateMath::log1p;
268 MAX_INT = AccurateMath::max;
269 MAX_LONG = AccurateMath::max;
270 MAX_FLOAT = AccurateMath::max;
271 MAX_DOUBLE = AccurateMath::max;
272 MIN_INT = AccurateMath::min;
273 MIN_LONG = AccurateMath::min;
274 MIN_FLOAT = AccurateMath::min;
275 MIN_DOUBLE = AccurateMath::min;
276 MULTIPLYEXACT_INT = AccurateMath::multiplyExact;
277 MULTIPLYEXACT_LONG = AccurateMath::multiplyExact;
278 NEGATEEXACT_INT = Math::negateExact;
279 NEGATEEXACT_LONG = Math::negateExact;
280 NEXTAFTER_FLOAT = AccurateMath::nextAfter;
281 NEXTAFTER_DOUBLE = AccurateMath::nextAfter;
282 NEXTDOWN_FLOAT = AccurateMath::nextDown;
283 NEXTDOWN_DOUBLE = AccurateMath::nextDown;
284 NEXTUP_FLOAT = AccurateMath::nextUp;
285 NEXTUP_DOUBLE = AccurateMath::nextUp;
286 POW = AccurateMath::pow;
287 RANDOM = Math::random;
288 RINT = AccurateMath::rint;
289 ROUND_DOUBLE = AccurateMath::round;
290 ROUND_FLOAT = AccurateMath::round;
291 SCALB_DOUBLE = AccurateMath::scalb;
292 SCALB_FLOAT = AccurateMath::scalb;
293 SIGNUM_DOUBLE = AccurateMath::signum;
294 SIGNUM_FLOAT = AccurateMath::signum;
295 SQRT = Math::sqrt;
296 SIN = AccurateMath::sin;
297 SINH = AccurateMath::sinh;
298 SUBTRACTEXACT_INT = AccurateMath::subtractExact;
299 SUBTRACTEXACT_LONG = AccurateMath::subtractExact;
300 TAN = AccurateMath::tan;
301 TANH = AccurateMath::tanh;
302 TODEGREES = AccurateMath::toDegrees;
303 TOINTEXACT = AccurateMath::toIntExact;
304 TORADIANS = AccurateMath::toRadians;
305 ULP_DOUBLE = AccurateMath::ulp;
306 ULP_FLOAT = AccurateMath::ulp;
307 break;
308
309 case JDK:
310 PI = Math.PI;
311 E = Math.E;
312 ABS_INT = Math::abs;
313 ABS_LONG = Math::abs;
314 ABS_FLOAT = Math::abs;
315 ABS_DOUBLE = Math::abs;
316 ACOS = Math::acos;
317 ACOSH = AccurateMath::acosh;
318 ADDEXACT_INT = Math::addExact;
319 ADDEXACT_LONG = Math::addExact;
320 ASIN = Math::asin;
321 ASINH = AccurateMath::asinh;
322 ATAN = Math::atan;
323 ATAN2 = Math::atan2;
324 ATANH = AccurateMath::atanh;
325 CBRT = Math::cbrt;
326 CEIL = Math::ceil;
327 COPYSIGN_FLOAT = Math::copySign;
328 COPYSIGN_DOUBLE = Math::copySign;
329 COS = Math::cos;
330 COSH = Math::cosh;
331 DECREMENTEXACT_INT = Math::decrementExact;
332 DECREMENTEXACT_LONG = Math::decrementExact;
333 EXP = Math::exp;
334 EXPM1 = Math::expm1;
335 FLOOR = Math::floor;
336 FLOORDIV_INT = Math::floorDiv;
337 FLOORDIV_LONG = Math::floorDiv;
338 FLOORMOD_INT = Math::floorMod;
339 FLOORMOD_LONG = Math::floorMod;
340 GETEXPONENT_FLOAT = Math::getExponent;
341 GETEXPONENT_DOUBLE = Math::getExponent;
342 HYPOT = Math::hypot;
343 IEEEREMAINDER = Math::IEEEremainder;
344 INCREMENTEXACT_INT = Math::incrementExact;
345 INCREMENTEXACT_LONG = Math::incrementExact;
346 LOG = Math::log;
347 LOG10 = Math::log10;
348 LOG1P = Math::log1p;
349 MAX_INT = Math::max;
350 MAX_LONG = Math::max;
351 MAX_FLOAT = Math::max;
352 MAX_DOUBLE = Math::max;
353 MIN_INT = Math::min;
354 MIN_LONG = Math::min;
355 MIN_FLOAT = Math::min;
356 MIN_DOUBLE = Math::min;
357 MULTIPLYEXACT_INT = Math::multiplyExact;
358 MULTIPLYEXACT_LONG = Math::multiplyExact;
359 NEGATEEXACT_INT = Math::negateExact;
360 NEGATEEXACT_LONG = Math::negateExact;
361 NEXTAFTER_FLOAT = Math::nextAfter;
362 NEXTAFTER_DOUBLE = Math::nextAfter;
363 NEXTDOWN_FLOAT = Math::nextDown;
364 NEXTDOWN_DOUBLE = Math::nextDown;
365 NEXTUP_FLOAT = Math::nextUp;
366 NEXTUP_DOUBLE = Math::nextUp;
367 POW = Math::pow;
368 RANDOM = Math::random;
369 RINT = Math::rint;
370 ROUND_DOUBLE = Math::round;
371 ROUND_FLOAT = Math::round;
372 SCALB_DOUBLE = Math::scalb;
373 SCALB_FLOAT = Math::scalb;
374 SIGNUM_DOUBLE = Math::signum;
375 SIGNUM_FLOAT = Math::signum;
376 SIN = Math::sin;
377 SINH = Math::sinh;
378 SQRT = Math::sqrt;
379 SUBTRACTEXACT_INT = Math::subtractExact;
380 SUBTRACTEXACT_LONG = Math::subtractExact;
381 TAN = Math::tan;
382 TANH = Math::tanh;
383 TODEGREES = Math::toDegrees;
384 TOINTEXACT = Math::toIntExact;
385 TORADIANS = Math::toRadians;
386 ULP_DOUBLE = Math::ulp;
387 ULP_FLOAT = Math::ulp;
388 break;
389
390 default:
391 throw new IllegalStateException("Internal error");
392 }
393 }
394
395
396 private JdkMath() {}
397
398
399
400
401
402
403
404 public static int abs(int x) {
405 return ABS_INT.applyAsInt(x);
406 }
407
408
409
410
411
412
413
414 public static long abs(long x) {
415 return ABS_LONG.applyAsLong(x);
416 }
417
418
419
420
421
422
423
424 public static float abs(float x) {
425 return ABS_FLOAT.applyAsFloat(x);
426 }
427
428
429
430
431
432
433
434 public static double abs(double x) {
435 return ABS_DOUBLE.applyAsDouble(x);
436 }
437
438
439
440
441
442
443
444 public static double acos(double x) {
445 return ACOS.applyAsDouble(x);
446 }
447
448
449
450
451
452 public static double acosh(double x) {
453 return ACOSH.applyAsDouble(x);
454 }
455
456
457
458
459
460
461
462
463 public static int addExact(int x,
464 int y) {
465 return ADDEXACT_INT.applyAsInt(x, y);
466 }
467
468
469
470
471
472
473
474
475 public static long addExact(long x,
476 long y) {
477 return ADDEXACT_LONG.applyAsLong(x, y);
478 }
479
480
481
482
483
484
485
486 public static double asin(double x) {
487 return ASIN.applyAsDouble(x);
488 }
489
490
491
492
493
494 public static double asinh(double x) {
495 return ASINH.applyAsDouble(x);
496 }
497
498
499
500
501
502
503
504 public static double atan(double x) {
505 return ATAN.applyAsDouble(x);
506 }
507
508
509
510
511
512
513
514
515 public static double atan2(double y,
516 double x) {
517 return ATAN2.applyAsDouble(y, x);
518 }
519
520
521
522
523
524 public static double atanh(double x) {
525 return ATANH.applyAsDouble(x);
526 }
527
528
529
530
531
532
533
534 public static double cbrt(double x) {
535 return CBRT.applyAsDouble(x);
536 }
537
538
539
540
541
542
543
544 public static double ceil(double x) {
545 return CEIL.applyAsDouble(x);
546 }
547
548
549
550
551
552
553
554
555 public static float copySign(float x,
556 float y) {
557 return COPYSIGN_FLOAT.applyAsFloat(x, y);
558 }
559
560
561
562
563
564
565
566
567 public static double copySign(double x,
568 double y) {
569 return COPYSIGN_DOUBLE.applyAsDouble(x, y);
570 }
571
572
573
574
575
576
577
578 public static double cos(double x) {
579 return COS.applyAsDouble(x);
580 }
581
582
583
584
585
586
587
588 public static double cosh(double x) {
589 return COSH.applyAsDouble(x);
590 }
591
592
593
594
595
596
597
598 public static int decrementExact(int x) {
599 return DECREMENTEXACT_INT.applyAsInt(x);
600 }
601
602
603
604
605
606
607
608 public static long decrementExact(long x) {
609 return DECREMENTEXACT_LONG.applyAsLong(x);
610 }
611
612
613
614
615
616
617
618 public static double exp(double x) {
619 return EXP.applyAsDouble(x);
620 }
621
622
623
624
625
626
627
628 public static double expm1(double x) {
629 return EXPM1.applyAsDouble(x);
630 }
631
632
633
634
635
636
637
638 public static double floor(double x) {
639 return FLOOR.applyAsDouble(x);
640 }
641
642
643
644
645
646
647
648
649 public static int floorDiv(int x,
650 int y) {
651 return FLOORDIV_INT.applyAsInt(x, y);
652 }
653
654
655
656
657
658
659
660
661 public static long floorDiv(long x,
662 long y) {
663 return FLOORDIV_LONG.applyAsLong(x, y);
664 }
665
666
667
668
669
670
671
672
673 public static int floorMod(int x,
674 int y) {
675 return FLOORMOD_INT.applyAsInt(x, y);
676 }
677
678
679
680
681
682
683
684
685 public static long floorMod(long x,
686 long y) {
687 return FLOORMOD_LONG.applyAsLong(x, y);
688 }
689
690
691
692
693
694
695
696 public static int getExponent(float x) {
697 return GETEXPONENT_FLOAT.applyAsInt(x);
698 }
699
700
701
702
703
704
705
706 public static int getExponent(double x) {
707 return GETEXPONENT_DOUBLE.applyAsInt(x);
708 }
709
710
711
712
713
714
715
716
717 public static double hypot(double x,
718 double y) {
719 return HYPOT.applyAsDouble(x, y);
720 }
721
722
723
724
725
726
727
728
729 public static double IEEEremainder(double x,
730 double y) {
731 return IEEEREMAINDER.applyAsDouble(x, y);
732 }
733
734
735
736
737
738
739
740 public static int incrementExact(int x) {
741 return INCREMENTEXACT_INT.applyAsInt(x);
742 }
743
744
745
746
747
748
749
750 public static long incrementExact(long x) {
751 return INCREMENTEXACT_LONG.applyAsLong(x);
752 }
753
754
755
756
757
758
759
760 public static double log(double x) {
761 return LOG.applyAsDouble(x);
762 }
763
764
765
766
767
768
769
770 public static double log10(double x) {
771 return LOG10.applyAsDouble(x);
772 }
773
774
775
776
777
778
779
780 public static double log1p(double x) {
781 return LOG1P.applyAsDouble(x);
782 }
783
784
785
786
787
788
789
790
791 public static int max(int x,
792 int y) {
793 return MAX_INT.applyAsInt(x, y);
794 }
795
796
797
798
799
800
801
802
803 public static long max(long x,
804 long y) {
805 return MAX_LONG.applyAsLong(x, y);
806 }
807
808
809
810
811
812
813
814
815 public static float max(float x,
816 float y) {
817 return MAX_FLOAT.applyAsFloat(x, y);
818 }
819
820
821
822
823
824
825
826
827 public static double max(double x,
828 double y) {
829 return MAX_DOUBLE.applyAsDouble(x, y);
830 }
831
832
833
834
835
836
837
838
839 public static int min(int x,
840 int y) {
841 return MIN_INT.applyAsInt(x, y);
842 }
843
844
845
846
847
848
849
850
851 public static long min(long x,
852 long y) {
853 return MIN_LONG.applyAsLong(x, y);
854 }
855
856
857
858
859
860
861
862
863 public static float min(float x,
864 float y) {
865 return MIN_FLOAT.applyAsFloat(x, y);
866 }
867
868
869
870
871
872
873
874
875 public static double min(double x,
876 double y) {
877 return MIN_DOUBLE.applyAsDouble(x, y);
878 }
879
880
881
882
883
884
885
886
887 public static int multiplyExact(int x,
888 int y) {
889 return MULTIPLYEXACT_INT.applyAsInt(x, y);
890 }
891
892
893
894
895
896
897
898
899 public static long multiplyExact(long x,
900 long y) {
901 return MULTIPLYEXACT_LONG.applyAsLong(x, y);
902 }
903
904
905
906
907
908
909
910 public static int negateExact(int x) {
911 return NEGATEEXACT_INT.applyAsInt(x);
912 }
913
914
915
916
917
918
919
920 public static long negateExact(long x) {
921 return NEGATEEXACT_LONG.applyAsLong(x);
922 }
923
924
925
926
927
928
929
930
931 public static double nextAfter(double x,
932 double y) {
933 return NEXTAFTER_DOUBLE.applyAsDouble(x, y);
934 }
935
936
937
938
939
940
941
942
943 public static float nextAfter(float x,
944 double y) {
945 return NEXTAFTER_FLOAT.applyAsFloat(x, y);
946 }
947
948
949
950
951
952
953
954 public static double nextDown(double x) {
955 return NEXTDOWN_DOUBLE.applyAsDouble(x);
956 }
957
958
959
960
961
962
963
964 public static float nextDown(float x) {
965 return NEXTDOWN_FLOAT.applyAsFloat(x);
966 }
967
968
969
970
971
972
973
974 public static double nextUp(double x) {
975 return NEXTUP_DOUBLE.applyAsDouble(x);
976 }
977
978
979
980
981
982
983
984 public static float nextUp(float x) {
985 return NEXTUP_FLOAT.applyAsFloat(x);
986 }
987
988
989
990
991
992
993
994
995 public static double pow(double x,
996 double y) {
997 return POW.applyAsDouble(x, y);
998 }
999
1000
1001
1002
1003
1004
1005 public static double random() {
1006 return RANDOM.getAsDouble();
1007 }
1008
1009
1010
1011
1012
1013
1014
1015 public static double rint(double x) {
1016 return RINT.applyAsDouble(x);
1017 }
1018
1019
1020
1021
1022
1023
1024
1025 public static int round(float x) {
1026 return ROUND_FLOAT.applyAsInt(x);
1027 }
1028
1029
1030
1031
1032
1033
1034
1035 public static long round(double x) {
1036 return ROUND_DOUBLE.applyAsLong(x);
1037 }
1038
1039
1040
1041
1042
1043
1044
1045
1046 public static double scalb(double x,
1047 int y) {
1048 return SCALB_DOUBLE.applyAsDouble(x, y);
1049 }
1050
1051
1052
1053
1054
1055
1056
1057
1058 public static float scalb(float x,
1059 int y) {
1060 return SCALB_FLOAT.applyAsFloat(x, y);
1061 }
1062
1063
1064
1065
1066
1067
1068
1069 public static double signum(double x) {
1070 return SIGNUM_DOUBLE.applyAsDouble(x);
1071 }
1072
1073
1074
1075
1076
1077
1078
1079 public static float signum(float x) {
1080 return SIGNUM_FLOAT.applyAsFloat(x);
1081 }
1082
1083
1084
1085
1086
1087
1088
1089 public static double sin(double x) {
1090 return SIN.applyAsDouble(x);
1091 }
1092
1093
1094
1095
1096
1097
1098
1099 public static double sinh(double x) {
1100 return SINH.applyAsDouble(x);
1101 }
1102
1103
1104
1105
1106
1107
1108
1109 public static double sqrt(double x) {
1110 return SQRT.applyAsDouble(x);
1111 }
1112
1113
1114
1115
1116
1117
1118
1119
1120 public static int subtractExact(int x,
1121 int y) {
1122 return SUBTRACTEXACT_INT.applyAsInt(x, y);
1123 }
1124
1125
1126
1127
1128
1129
1130
1131
1132 public static long subtractExact(long x,
1133 long y) {
1134 return SUBTRACTEXACT_LONG.applyAsLong(x, y);
1135 }
1136
1137
1138
1139
1140
1141
1142
1143 public static double tan(double x) {
1144 return TAN.applyAsDouble(x);
1145 }
1146
1147
1148
1149
1150
1151
1152
1153 public static double tanh(double x) {
1154 return TANH.applyAsDouble(x);
1155 }
1156
1157
1158
1159
1160
1161
1162
1163 public static double toDegrees(double x) {
1164 return TODEGREES.applyAsDouble(x);
1165 }
1166
1167
1168
1169
1170
1171
1172
1173 public static int toIntExact(long x) {
1174 return TOINTEXACT.applyAsInt(x);
1175 }
1176
1177
1178
1179
1180
1181
1182
1183 public static double toRadians(double x) {
1184 return TORADIANS.applyAsDouble(x);
1185 }
1186
1187
1188
1189
1190
1191
1192
1193 public static double ulp(double x) {
1194 return ULP_DOUBLE.applyAsDouble(x);
1195 }
1196
1197
1198
1199
1200
1201
1202
1203 public static float ulp(float x) {
1204 return ULP_FLOAT.applyAsFloat(x);
1205 }
1206
1207
1208 private interface FloatUnaryOperator {
1209
1210
1211
1212
1213 float applyAsFloat(float x);
1214 }
1215
1216
1217 private interface FloatBinaryOperator {
1218
1219
1220
1221
1222
1223 float applyAsFloat(float x, float y);
1224 }
1225
1226
1227 private interface FloatDouble2FloatOperator {
1228
1229
1230
1231
1232
1233 float applyAsFloat(float x, double y);
1234 }
1235
1236
1237 private interface FloatToIntFunction {
1238
1239
1240
1241
1242 int applyAsInt(float x);
1243 }
1244
1245
1246 private interface FloatInt2FloatOperator {
1247
1248
1249
1250
1251
1252 float applyAsFloat(float x, int y);
1253 }
1254
1255
1256 private interface DoubleInt2DoubleOperator {
1257
1258
1259
1260
1261
1262 double applyAsDouble(double x, int y);
1263 }
1264 }