public static List<KafkaServerStartable> startServers(final int brokerCount, final int port, final String zkStr, final Properties configuration) { List<KafkaServerStartable> startables = new ArrayList<>(brokerCount); for (int i = 0; i < brokerCount; i++) { startables.add(startServer(port + i, i, zkStr, "/tmp/kafka-" + Double.toHexString(Math.random()), configuration)); } return startables; }
public static KafkaServerStartable startServer(final int port, final int brokerId, final String zkStr, final Properties configuration) { return startServer(port, brokerId, zkStr, "/tmp/kafka-" + Double.toHexString(Math.random()), configuration); }
@GwtIncompatible // Doubles.tryParse public void testTryParseOfToHexStringIsOriginal() { for (double d : NUMBERS) { checkTryParse(d, Double.toHexString(d)); } }
private void transformA(StringBuilder result) { if (arg instanceof Float) { result.append(Float.toHexString(((Float) arg).floatValue())); } else if (arg instanceof Double) { result.append(Double.toHexString(((Double) arg).doubleValue())); } else { throw badArgumentType(); } if (!formatToken.isPrecisionSet()) { return; } int precision = formatToken.getPrecision(); if (precision == 0) { precision = 1; } int indexOfFirstFractionalDigit = result.indexOf(".") + 1; int indexOfP = result.indexOf("p"); int fractionalLength = indexOfP - indexOfFirstFractionalDigit; if (fractionalLength == precision) { return; } if (fractionalLength < precision) { char[] zeros = new char[precision - fractionalLength]; Arrays.fill(zeros, '0'); // %a shouldn't be localized. result.insert(indexOfP, zeros); return; } result.delete(indexOfFirstFractionalDigit + precision, indexOfP); }
@Override public void visit(WasmFloat64Constant expression) { open().append("f64.const " + Double.toHexString(expression.getValue())).close(); }
@Override public void visit(WasmFloat64Constant expression) { if (Double.isInfinite(expression.getValue())) { value = CExpression.relocatable(expression.getValue() < 0 ? "-INFINITY" : "INFINITY"); } else if (Double.isNaN(expression.getValue())) { value = CExpression.relocatable("NAN"); } else { value = CExpression.relocatable(Double.toHexString(expression.getValue())); } }
if (_hex_string) { s = Double.toHexString(d);
public static KafkaServerStartable startServer(final int port, final int brokerId, final String zkStr, final Properties configuration) { // Create the ZK nodes for Kafka, if needed int indexOfFirstSlash = zkStr.indexOf('/'); if (indexOfFirstSlash != -1) { String bareZkUrl = zkStr.substring(0, indexOfFirstSlash); String zkNodePath = zkStr.substring(indexOfFirstSlash); ZkClient client = new ZkClient(bareZkUrl); client.createPersistent(zkNodePath, true); client.close(); } File logDir = new File("/tmp/kafka-" + Double.toHexString(Math.random())); logDir.mkdirs(); configureKafkaPort(configuration, port); configureZkConnectionString(configuration, zkStr); configureBrokerId(configuration, brokerId); configureKafkaLogDirectory(configuration, logDir); KafkaConfig config = new KafkaConfig(configuration); KafkaServerStartable serverStartable = new KafkaServerStartable(config); serverStartable.startup(); return serverStartable; }
private String myDoubleToString(double d) { if (Double.isNaN(d)) { return "NA"; } return useDecimalOutput? Double.toString(d) : Double.toHexString(d); }
@JTranscSync public static String toHexString(float value) { return Double.toHexString(value); }
public static String anonUri(String namespace, String hint) { if (hint == null) { hint = Double.toHexString(System.currentTimeMillis()); } return namespace + hash(hint); }
class Test { public static void main(String[] args) { System.out.println("3.2F is: "+Float.toHexString(3.2F)); System.out.println("3.2 is: "+Double.toHexString(3.2)); System.out.println("6.5F is: "+Float.toHexString(6.5F)); System.out.println("6.5 is: "+Double.toHexString(6.5)); } } $ java Test 3.2F is: 0x1.99999ap1 3.2 is: 0x1.999999999999ap1 6.5F is: 0x1.ap2 6.5 is: 0x1.ap2
/** * override * * @see Double#toHexString(double) */ private static Result toHexString(MethodCode methodCode, MethodArgs methodArgs, Frame frame) { double d = (double) methodArgs.invokeArgs[0]; String s = Double.toHexString(d); ObjectRef ref = frame.heap.newString(s); Result result = NativeMethod.result(methodCode, ref, frame); return result; }
@Override public void visit(WasmFloat64Constant expression) { value = CExpression.relocatable(Double.toHexString(expression.getValue())); }
public static void main(String[] args) { findMaxDouble(); double belowOne = Math.nextAfter(1.0, 0.0); System.out.println("Biggest double below 1.0 is: " + Double.toHexString(belowOne) + " = " + belowOne); findMinDouble(); } }
@Override public void visit(WasmFloat64Constant expression) { open().append("f64.const " + Double.toHexString(expression.getValue())).close(); }
@Benchmark int stringIntern(int reps) { for (int i = 0; i < reps; i++) { String unused = Double.toHexString(Math.random()).intern(); } return reps; } }
@GwtIncompatible // Doubles.tryParse public void testTryParseOfToHexStringIsOriginal() { for (double d : NUMBERS) { checkTryParse(d, Double.toHexString(d)); } }
@Benchmark int weakInterner(int reps) { Interner<String> interner = Interners.newWeakInterner(); for (int i = 0; i < reps; i++) { interner.intern(Double.toHexString(Math.random())); } return reps; }
@Benchmark int strongInterner(int reps) { Interner<String> interner = Interners.newStrongInterner(); for (int i = 0; i < reps; i++) { interner.intern(Double.toHexString(Math.random())); } return reps; }