comparison dwt/dwthelper/Integer.d @ 0:5406a8f6526d

Add initial files
author John Reimer <terminal.node@gmail.com
date Sun, 20 Jan 2008 21:50:55 -0800
parents
children 1bea9f0c6f63
comparison
equal deleted inserted replaced
-1:000000000000 0:5406a8f6526d
1 /**
2 * Authors: Frank Benoit <keinfarbton@googlemail.com>
3 */
4
5 module dwt.dwthelper.Integer;
6
7 import dwt.dwthelper.utils;
8
9 static import tango.text.convert.Integer;
10
11 public final class Integer {
12
13 public static int MIN_VALUE = 0x80000000;
14 public static int MAX_VALUE = 0x7fffffff;
15 public static int SIZE = 32;
16
17 public int value;
18 public this ( int value ){
19 this.value = value;
20 }
21
22 public this ( char[] s ){
23 }
24
25 public static char[] toString( int i, int radix ){
26 switch( radix ){
27 case 2:
28 return toBinaryString(i);
29 case 8:
30 return toOctalString(i);
31 case 10:
32 return toString(i);
33 case 16:
34 return toHexString(i);
35 default:
36 implMissing( __FILE__, __LINE__ );
37 return null;
38 }
39 }
40
41 public static char[] toHexString( int i ){
42 return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Hex );
43 }
44
45 public static char[] toOctalString( int i ){
46 return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Octal );
47 }
48
49 public static char[] toBinaryString( int i ){
50 return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Binary );
51 }
52
53 public static char[] toString( int i ){
54 return tango.text.convert.Integer.toString(i);
55 }
56
57 public static int parseInt( char[] s, int radix ){
58 return tango.text.convert.Integer.parse( s, cast(uint)radix );
59 }
60
61 public static int parseInt( char[] s ){
62 return tango.text.convert.Integer.parse( s );
63 }
64
65 public static Integer valueOf( char[] s, int radix ){
66 implMissing( __FILE__, __LINE__ );
67 return null;
68 }
69
70 public static Integer valueOf( char[] s ){
71 implMissing( __FILE__, __LINE__ );
72 return null;
73 }
74
75 public static Integer valueOf( int i ){
76 implMissing( __FILE__, __LINE__ );
77 return null;
78 }
79
80 public byte byteValue(){
81 return cast(byte)value;
82 }
83
84 public short shortValue(){
85 return cast(short)value;
86 }
87
88 public int intValue(){
89 return value;
90 }
91
92 public long longValue(){
93 return cast(long)value;
94 }
95
96 public float floatValue(){
97 return cast(float)value;
98 }
99
100 public double doubleValue(){
101 return cast(double)value;
102 }
103
104 public override hash_t toHash(){
105 return intValue();
106 }
107
108 public override int opEquals( Object obj ){
109 implMissing( __FILE__, __LINE__ );
110 return false;
111 }
112
113 public override char[] toString(){
114 return tango.text.convert.Integer.toString( value );
115 }
116 }
117
118