File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed
sources/net.sf.j2s.java.core/src/javajs/util Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ public static String formatDecimal(float value, int decimalDigits) {
118118 n = PT .parseInt (s1 .substring (pt1 + 1 ));
119119 // 3.567E-2
120120 // 0.03567
121+ // -0.0001
121122 s1 = "0." + zeros .substring (0 , -n - 1 ) + s1 .substring (0 , 1 ) + s1 .substring (2 , pt1 );
122123 pt = 1 ;
123124 }
@@ -142,8 +143,11 @@ public static String formatDecimal(float value, int decimalDigits) {
142143 value + (isNeg ? -1 : 1 ) * formatAdds [decimalDigits ], decimalDigits );
143144 }
144145
145- SB sb = SB .newS (s1 .substring (0 , (decimalDigits == 0 ? pt
146- : ++pt )));
146+ String s0 = s1 .substring (0 , (decimalDigits == 0 ? pt
147+ : ++pt ));
148+ SB sb = SB .newS (s0 );
149+ if (isNeg && s0 .equals ("0." ) && decimalDigits + 2 <= len && s1 .substring (2 , 2 + decimalDigits ).equals (zeros .substring (0 , decimalDigits )))
150+ isNeg = false ;
147151 for (int i = 0 ; i < decimalDigits ; i ++, pt ++) {
148152 if (pt < len )
149153 sb .appendC (s1 .charAt (pt ));
Original file line number Diff line number Diff line change @@ -816,13 +816,12 @@ public static String toJSON(String infoType, Object info) {
816816 while (true ) {
817817 if (info instanceof String ) {
818818 s = (String ) info ;
819- /**
820- * @j2sNative
821- *
822- * if (typeof s == "undefined") s = "null"
823- *
824- */
825- {}
819+ // /**
820+ // * @j2sNative
821+ // *
822+ // * if (typeof s == "undefined") s = "null"
823+ // *
824+ // */
826825
827826 if (s .indexOf ("{\" " ) != 0 ) {
828827 //don't doubly fix JSON strings when retrieving status
You can’t perform that action at this time.
0 commit comments