Here you can find the source of double2sortableStr(double val)
public static String double2sortableStr(double val)
//package com.java2s; //License from project: Apache License public class Main { public static String double2sortableStr(double val) { long f = Double.doubleToRawLongBits(val); if (f < 0) f ^= 0x7fffffffffffffffL;/*from w ww . java2s . c o m*/ return long2sortableStr(f); } public static String double2sortableStr(String val) { return double2sortableStr(Double.parseDouble(val)); } public static String long2sortableStr(long val) { char[] arr = new char[5]; long2sortableStr(val, arr, 0); return new String(arr, 0, 5); } public static String long2sortableStr(String val) { return long2sortableStr(Long.parseLong(val)); } public static int long2sortableStr(long val, char[] out, int offset) { val += Long.MIN_VALUE; out[offset++] = (char) (val >>> 60); out[offset++] = (char) (val >>> 45 & 0x7fff); out[offset++] = (char) (val >>> 30 & 0x7fff); out[offset++] = (char) (val >>> 15 & 0x7fff); out[offset] = (char) (val & 0x7fff); return 5; } }