MCPcopy Create free account
hub / github.com/davidgiven/luje / toHexString

Method toHexString

lib/java/lang/Long.java:413–437  ·  view source on GitHub ↗

Converts the specified long value into its hexadecimal string representation. The returned string is a concatenation of characters from '0' to '9' and 'a' to 'f'. @param l the long value to convert. @return the hexadecimal string representation of l.

(long l)

Source from the content-addressed store, hash-verified

411 * @return the hexadecimal string representation of {@code l}.
412 */
413 public static String toHexString(long l) {
414 int count = 1;
415 long j = l;
416
417 if (l < 0) {
418 count = 16;
419 } else {
420 while ((j >>= 4) != 0) {
421 count++;
422 }
423 }
424
425 char[] buffer = new char[count];
426 do {
427 int t = (int) (l & 15);
428 if (t > 9) {
429 t = t - 10 + 'a';
430 } else {
431 t += '0';
432 }
433 buffer[--count] = (char) t;
434 l >>= 4;
435 } while (count > 0);
436 return new String(0, buffer.length, buffer);
437 }
438
439 /**
440 * Converts the specified long value into its octal string representation.

Callers 1

toHexStringMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected