1 module java.lang.Double;
2 
3 import java.lang.util;
4 import java.lang.exceptions;
5 import java.lang.Number;
6 import java.lang.Class;
7 import java.lang.String;
8 
9 version(Tango){
10     static import tango.text.convert.Float;
11 } else { // Phobos
12     static import std.conv;
13 }
14 
15 class Double : Number {
16     public static double POSITIVE_INFINITY = double.infinity;
17     public static double NEGATIVE_INFINITY = -double.infinity;
18     public static double MAX_VALUE = double.max;
19     public static double MIN_VALUE = double.min_normal;
20     private double value = 0;
21     this( double value ){
22         super();
23         this.value = value;
24     }
25     this( String str ){
26         super();
27         this.value = parseDouble(str);
28     }
29     public static String toString( double value ){
30         return String_valueOf(value);
31     }
32     public static double parseDouble(String s){
33         version(Tango){
34             try{
35                 return tango.text.convert.Float.toFloat( s );
36             }
37             catch( IllegalArgumentException e ){
38                 throw new NumberFormatException( e );
39             }
40         } else { // Phobos
41             try{
42                 return std.conv.to!(double)(s);
43             }
44             catch( std.conv.ConvException e ){
45                 throw new NumberFormatException( e );
46             }
47         }
48     }
49 
50     private static Class TYPE_;
51     public static Class TYPE(){
52         if( TYPE_ is null ){
53             TYPE_ = Class.fromType!(double);
54         }
55         return TYPE_;
56     }
57 
58     override
59     public byte byteValue(){
60         return cast(byte)value;
61     }
62 
63     override
64     public short shortValue(){
65         return cast(short)value;
66     }
67 
68     override
69     public int intValue(){
70         return cast(int)value;
71     }
72 
73     override
74     public long longValue(){
75         return cast(long)value;
76     }
77 
78     override
79     public float floatValue(){
80         return cast(float)value;
81     }
82 
83     override
84     public double doubleValue(){
85         return cast(double)value;
86     }
87 }
88 
89