MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / toHexString

Method toHexString

unused/sun/security/util/Debug.java:146–174  ·  view source on GitHub ↗

return a hexadecimal printed representation of the specified BigInteger object. the value is formatted to fit on lines of at least 75 characters, with embedded newlines. Words are separated for readability, with eight words (32 bytes) per line.

(BigInteger b)

Source from the content-addressed store, hash-verified

144 * separated for readability, with eight words (32 bytes) per line.
145 */
146 public static String toHexString(BigInteger b) {
147 String hexValue = b.toString(16);
148 StringBuffer buf = new StringBuffer(hexValue.length()*2);
149
150 if (hexValue.startsWith("-")) {
151 buf.append(" -");
152 hexValue = hexValue.substring(1);
153 } else {
154 buf.append(" "); // four spaces
155 }
156 if ((hexValue.length()%2) != 0) {
157 // add back the leading 0
158 hexValue = "0" + hexValue;
159 }
160 int i=0;
161 while (i < hexValue.length()) {
162 // one byte at a time
163 buf.append(hexValue.substring(i, i+2));
164 i+=2;
165 if (i!= hexValue.length()) {
166 if ((i%64) == 0) {
167 buf.append("\n "); // line after eight words
168 } else if (i%8 == 0) {
169 buf.append(" "); // space between words
170 }
171 }
172 }
173 return buf.toString();
174 }
175 }

Callers

nothing calls this directly

Calls 3

lengthMethod · 0.80
appendMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected