forked from BobHanson/java2script
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFloat.js0
More file actions
119 lines (111 loc) · 2.77 KB
/
Float.js0
File metadata and controls
119 lines (111 loc) · 2.77 KB
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
// DEPRECATED -- SEE J2SSwingJS.js
Clazz.load (["java.lang.Comparable", "$.Number"], "java.lang.Float", null, function () {
java.lang.Float = Float = function () {
Clazz.instantialize (this, arguments);
};
Clazz.decorateAsType (Float, "Float", Number, Comparable, null, true);
Float.prototype.valueOf = function () { return 0; };
Float.toString = Float.prototype.toString = function () {
if (arguments.length != 0) {
return "" + arguments[0];
} else if (this === Float) {
return "class java.lang.Float"; // Float.class.toString
}
return "" + this.valueOf ();
};
/*
Clazz.makeConstructor (Float,
function () {
this.valueOf = function () {
return 0.0;
};
});
Clazz.makeConstructor (Float,
function (value) {
this.valueOf = function () {
return value;
};
}, "Number");
Clazz.makeConstructor (Float,
function (s) {
var value = null;
if (s != null) {
value = Float.parseFloat (s);
} else {
value = 0;
}
this.valueOf = function () {
return value;
};
}, "String");
// */
Clazz.makeConstructor (Float,
function (s) {
var v = 0.0;
if (arguments.length > 0) {
if (typeof s == "string") {
v = Float.parseFloat (s);
} else {
v = s;
}
}
this.valueOf = function () {
return v;
};
}, "Object");
Float.serialVersionUID = Float.prototype.serialVersionUID = -2671257302660747028;
Float.MIN_VALUE = Float.prototype.MIN_VALUE = 3.4028235e+38;
Float.MAX_VALUE = Float.prototype.MAX_VALUE = 1.4e-45;
Float.NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY;
Float.POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
Float.NaN = Number.NaN;
Float.TYPE = Float.prototype.TYPE = Float;
Clazz.defineMethod (Float, "parseFloat",
function (s) {
if (s == null) {
throw new NumberFormatException ("null");
}
var floatVal = parseFloat (s);
if(isNaN(floatVal)){
throw new NumberFormatException ("Not a Number : " + s);
}
return floatVal;
}, "String");
Float.parseFloat = Float.prototype.parseFloat;
/*
Clazz.defineMethod (Float, "$valueOf",
function (s) {
return new Float(Float.parseFloat (s, 10));
}, "String");
Clazz.defineMethod (Float, "$valueOf",
function (s) {
return new Float(s);
}, "Number");
Float.$valueOf = Float.prototype.$valueOf;
// */
Float.$valueOf = Float.prototype.$valueOf = function (s) {
if (typeof s == "string") { // String
return new Float(Float.parseFloat (s, 10));
} else {
return new Float(s);
}
};
Clazz.defineMethod (Float, "isNaN",
function (num) {
return isNaN (num);
}, "Number");
Float.isNaN = Float.prototype.isNaN;
Clazz.defineMethod (Float, "isInfinite",
function (num) {
return !isFinite (num);
}, "Number");
Float.isInfinite = Float.prototype.isInfinite;
Float.prototype.hashCode = JavaObject.prototype.hashCode;
Clazz.overrideMethod (Float, "equals",
function (s) {
if(s == null || ! Clazz.instanceOf(s, Float) ){
return false;
}
return s.valueOf() == this.valueOf();
}, "Object");
});