MCPcopy Index your code
hub / github.com/ccxt/ccxt / toString

Method toString

java/lib/src/main/java/io/github/ccxt/base/Precise.java:180–220  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

178 }
179
180 @Override
181 public String toString() {
182 this.reduce();
183 String sign = "";
184 BigInteger abs;
185 if (this.integer.compareTo(BigInteger.ZERO) < 0) {
186 sign = "-";
187 abs = this.integer.negate();
188 } else {
189 abs = this.integer;
190 }
191 String absParsed = abs.toString();
192
193 int padSize = Math.max(toInt(this.decimals), 0);
194 String padded = leftPad(absParsed, Math.max(padSize, absParsed.length()), '0');
195
196 List<String> integerArray = new ArrayList<>(padded.length());
197 for (int i = 0; i < padded.length(); i++) {
198 integerArray.add(String.valueOf(padded.charAt(i)));
199 }
200
201 int index = integerArray.size() - toInt(this.decimals);
202
203 String item;
204 if (index == 0) {
205 item = "0.";
206 } else if (toInt(this.decimals) < 0) {
207 item = repeat('0', -toInt(this.decimals));
208 } else if (toInt(this.decimals) == 0) {
209 item = "";
210 } else {
211 item = ".";
212 }
213
214 int arrayIndex = Math.min(index, integerArray.size());
215 integerArray.add(arrayIndex, item);
216
217 StringBuilder sb = new StringBuilder(sign);
218 for (String s : integerArray) sb.append(s);
219 return sb.toString();
220 }
221
222 // -------- static string ops --------
223 public static String stringMul(Object string1, Object string2) {

Callers 15

stringDivMethod · 0.95
binaryToHexMethod · 0.45
binaryToBase58Method · 0.45
encodeURIComponentMethod · 0.45
BaseUIDMethod · 0.45
uuid2Method · 0.45
sortBy2Method · 0.45
filterByMethod · 0.45
indexByMethod · 0.45
mulMethod · 0.45
divMethod · 0.45

Calls 9

reduceMethod · 0.95
toIntMethod · 0.95
leftPadMethod · 0.95
repeatMethod · 0.95
maxMethod · 0.45
lengthMethod · 0.45
addMethod · 0.45
minMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected