1 module java.lang.Math;
2 
3 version(Tango){
4     static import tango.math.Math;
5     alias tango.math.Math MathLib;
6 } else {
7     static import std.math;
8     alias std.math MathLib;
9 }
10 
11 class Math {
12 
13     public static immutable double PI = MathLib.PI;
14 
15     static double abs(double a){ return a > 0 ? a : -a; }
16     static float  abs(float  a){ return a > 0 ? a : -a; }
17     static int    abs(int    a){ return a > 0 ? a : -a; }
18     static long   abs(long   a){ return a > 0 ? a : -a; }
19 
20     static typeof(T1.init < T2.init ? T1.init : T2.init) min(T1, T2)(T1 a, T2 b){ return a < b ? a : b; }
21     static typeof(T1.init > T2.init ? T1.init : T2.init) max(T1, T2)(T1 a, T2 b){ return a > b ? a : b; }
22 
23 
24     static double sin(double a)  { return MathLib.sin(a); }
25     static double cos(double a)  { return MathLib.cos(a); }
26 
27     static long   round(double a) { return cast(long)MathLib.round(a); }
28     static int    round(float a)  { return cast(int)MathLib.round(a); }
29     static int    round(int a)  { return a; }
30     static double rint(double a) {
31         version(Tango) return MathLib.rndint(a);
32         else           return MathLib.rint(a);
33     }
34     static double ceil(double a) { return MathLib.ceil(a); }
35     static double floor(double a) { return MathLib.floor(a); }
36     static double sqrt(double a) { return MathLib.sqrt(a); }
37     static double atan2(double a, double b) { return MathLib.atan2(a,b); }
38     static double pow(double a, double b) { return MathLib.pow(a, b); }
39 }
40 
41