Skip to content

Commit fdedad7

Browse files
committed
// BH 2021.12.19 adds Double -0; fixes println(Double)
1 parent b00a70e commit fdedad7

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed
133 Bytes
Binary file not shown.

sources/net.sf.j2s.java.core/srcjs/swingjs2.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14023,6 +14023,7 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
1402314023

1402414024
// Google closure compiler cannot handle Clazz.new or Clazz.super
1402514025

14026+
// BH 2021.12.19 adds Double -0
1402614027
// BH 2021.12.15 default encoding for String.getBytes() should be utf-8.
1402714028
// BH 2021.08.16 fix for Interface initializing its subclass with static initialization
1402814029
// BH 2021.07.28 String.instantialize upgraded to use TextDecoder() if possible (not in MSIE)
@@ -17279,13 +17280,20 @@ ps.printf = ps.printf$S$OA = ps.format = ps.format$S$OA = function (f, args) {
1727917280

1728017281
ps.flush$ = function() {}
1728117282

17282-
ps.println = ps.println$ = ps.println$O = ps.println$Z = ps.println$I = ps.println$S = ps.println$C = function(s) {
17283+
ps.println = ps.println$ = ps.println$Z = ps.println$I = ps.println$S = ps.println$C = function(s) {
1728317284
s = (typeof s == "undefined" ? "" : "" + s);
1728417285
checkTrace(s);
1728517286
s = (typeof s == "undefined" ? "\r\n" : s == null ? s = "null\r\n" : s + "\r\n");
1728617287
f(s);
1728717288
};
1728817289

17290+
ps.println$O = function(s) {
17291+
s = (typeof s == "undefined" ? "" : s.toString());
17292+
checkTrace(s);
17293+
s = (typeof s == "undefined" ? "\r\n" : s == null ? s = "null\r\n" : s + "\r\n");
17294+
f(s);
17295+
};
17296+
1728917297
ps.println$J = function(l) {ps.println(Long.$s(l))}
1729017298
ps.println$F = ps.println$D = function(f) {var s = "" + f; ps.println(s.indexOf(".") < 0 && s.indexOf("Inf") < 0 ? s + ".0" : s)};
1729117299

@@ -19218,6 +19226,9 @@ function(n){
1921819226
}, 1);
1921919227

1922019228
Clazz._floatToString = function(f) {
19229+
if (f === 0) {
19230+
return (1/f == -Infinity ? "-0.0" : "0.0");
19231+
}
1922119232
var check57 = (Math.abs(f) >= 1e-6 && Math.abs(f) < 1e-3);
1922219233
if (check57)
1922319234
f/=1e7;
@@ -19245,7 +19256,7 @@ var maxFloat = 3.4028235E38;
1924519256
var minFloat = -3.4028235E38;
1924619257

1924719258
m$(Float,"c$", function(v){
19248-
v || v == null || v != v || (v = 0);
19259+
v || v == null || v != v || (v == 0) || (v = 0);
1924919260
if (typeof v != "number")
1925019261
v = Float.parseFloat$S(v);
1925119262
this.valueOf=function(){return v;}
@@ -19261,6 +19272,7 @@ m$(Float, "c$$S", function(v){
1926119272
}, 1);
1926219273

1926319274
m$(Float, "c$$D", function(v){
19275+
v || (v = 0);
1926419276
v = (v < minFloat ? -Infinity : v > maxFloat ? Infinity : v);
1926519277
this.valueOf=function(){return v;}
1926619278
}, 1);
@@ -19391,18 +19403,19 @@ return Clazz._floatToString(this.valueOf());
1939119403
};
1939219404

1939319405
m$(Double, "c$$D", function(v){
19406+
v || (v = 0);
1939419407
this.valueOf=function(){return v;};
1939519408
}, 1);
1939619409

1939719410
m$(Double,"c$", function(v){
19398-
v || v == null || v != v || (v = 0);
19411+
v || v == null || v != v || (v == 0) || (v = 0);
1939919412
if (typeof v != "number")
1940019413
v = Double.parseDouble$S(v);
1940119414
this.valueOf=function(){return v;}
1940219415
}, 1);
1940319416

1940419417
m$(Double, ["c$$S"], function(v){
19405-
v || v == null || (v = 0);
19418+
v || v == null || (v == 0) || (v = 0);
1940619419
if (typeof v != "number")
1940719420
v = Double.parseDouble$S(v);
1940819421
this.valueOf=function(){return v;};

0 commit comments

Comments
 (0)