java.lang.Double.toHexString()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(211)

本文整理了Java中java.lang.Double.toHexString()方法的一些代码示例,展示了Double.toHexString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Double.toHexString()方法的具体详情如下:
包路径:java.lang.Double
类名称:Double
方法名:toHexString

Double.toHexString介绍

[英]Converts the specified double into its hexadecimal string representation.
[中]

代码示例

代码示例来源:origin: apache/incubator-pinot

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;
}

代码示例来源:origin: apache/incubator-pinot

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);
}

代码示例来源:origin: google/guava

@GwtIncompatible // Doubles.tryParse
public void testTryParseOfToHexStringIsOriginal() {
 for (double d : NUMBERS) {
  checkTryParse(d, Double.toHexString(d));
 }
}

代码示例来源:origin: robovm/robovm

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);
}

代码示例来源:origin: konsoletyper/teavm

@Override
public void visit(WasmFloat64Constant expression) {
  open().append("f64.const " + Double.toHexString(expression.getValue())).close();
}

代码示例来源:origin: konsoletyper/teavm

@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()));
  }
}

代码示例来源:origin: h2oai/h2o-2

if (_hex_string) {
 s = Double.toHexString(d);

代码示例来源:origin: uber/chaperone

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;
}

代码示例来源:origin: ai.h2o/h2o-genmodel

private String myDoubleToString(double d) {
 if (Double.isNaN(d)) {
  return "NA";
 }
 return useDecimalOutput? Double.toString(d) : Double.toHexString(d);
}

代码示例来源:origin: com.jtransc/jtransc-rt

@JTranscSync
public static String toHexString(float value) {
  return Double.toHexString(value);
}

代码示例来源:origin: bio2rdf/bio2rdf-scripts

public static String anonUri(String namespace, String hint) {
  if (hint == null) {
    hint = Double.toHexString(System.currentTimeMillis());
  }
  return namespace + hash(hint);
}

代码示例来源:origin: stackoverflow.com

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

代码示例来源:origin: nuls-io/nuls

/**
 * 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;
}

代码示例来源:origin: org.teavm/teavm-core

@Override
public void visit(WasmFloat64Constant expression) {
  value = CExpression.relocatable(Double.toHexString(expression.getValue()));
}

代码示例来源:origin: kabutz/javaspecialists

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();
  }
}

代码示例来源:origin: org.teavm/teavm-core

@Override
public void visit(WasmFloat64Constant expression) {
  open().append("f64.const " + Double.toHexString(expression.getValue())).close();
}

代码示例来源:origin: com.google.guava/guava-tests

@Benchmark int stringIntern(int reps) {
  for (int i = 0; i < reps; i++) {
   String unused = Double.toHexString(Math.random()).intern();
  }
  return reps;
 }
}

代码示例来源:origin: com.google.guava/guava-tests

@GwtIncompatible // Doubles.tryParse
public void testTryParseOfToHexStringIsOriginal() {
 for (double d : NUMBERS) {
  checkTryParse(d, Double.toHexString(d));
 }
}

代码示例来源:origin: com.google.guava/guava-tests

@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;
}

代码示例来源:origin: com.google.guava/guava-tests

@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;
}

相关文章