Here you can find the source of unsignedLongToString(long value)
private static String unsignedLongToString(long value)
//package com.java2s; /* Copyright (c) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License./*from w w w. j a va 2 s. c o m*/ */ public class Main { /** * Treats the provided long as unsigned and converts it to a string. */ private static String unsignedLongToString(long value) { if (value >= 0) { return Long.toString(value); } else { // Split into two unsigned halves. As digits are printed out from // the bottom half, move data from the top half into the bottom // half int max_dig = 20; char[] cbuf = new char[max_dig]; int radix = 10; int dst = max_dig; long top = value >>> 32; long bot = value & 0xffffffffl; bot += (top % radix) << 32; top /= radix; while (bot > 0 || top > 0) { cbuf[--dst] = Character.forDigit((int) (bot % radix), radix); bot = (bot / radix) + ((top % radix) << 32); top /= radix; } return new String(cbuf, dst, max_dig - dst); } } }