java.lang.Float.doubleValue()方法的使用及代码示例

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

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

Float.doubleValue介绍

[英]Returns the double value of this Float object.
[中]

代码示例

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

private static boolean mixedFloatEquality( Float a, Double b )
  {
    return a.doubleValue() == b;
  }
}

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

public Double toDouble(Float self) {
  return self.doubleValue();
}

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

@Override
public Double toDouble(Object value) {
 return ((Float) value).doubleValue();
}

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

public void set(String key, Float value) {
  if (value != null) {
    attributes.put(key, value.doubleValue());
  }
}

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

@Override
public Double asDouble() {
  if (value instanceof Double) return (Double) value;
  if (value instanceof Float) return Double.valueOf(((Float) value).doubleValue());
  if (value instanceof Number) return ((Number)value).doubleValue();
  return null;
}

代码示例来源:origin: apache/flink

private double convertToDouble(Object o, double defaultValue) {
  if (o.getClass() == Double.class) {
    return (Double) o;
  }
  else if (o.getClass() == Float.class) {
    return ((Float) o).doubleValue();
  }
  else {
    try {
      return Double.parseDouble(o.toString());
    }
    catch (NumberFormatException e) {
      LOG.warn("Configuration cannot evaluate value {} as a double value", o);
      return defaultValue;
    }
  }
}

代码示例来源:origin: chanjarster/weixin-java-tools

public static void main(String[] args) {
  Float a = 3.1f;
  System.out.println(3.1d);
  System.out.println(new BigDecimal(3.1d));
  System.out.println(new BigDecimal(a));
  System.out.println(a.toString());
  System.out.println(a.doubleValue());
 }
}

代码示例来源:origin: MovingBlocks/Terasology

@Override
  public void set(Float value) {
    fieldMetadata.setValue(target, value.doubleValue());
  }
};

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

@Override
public double getDoubleValue(int dictId) {
 return ((Float) get(dictId)).doubleValue();
}

代码示例来源:origin: org.codehaus.groovy/groovy

public final Object call(Object receiver, Object arg) throws Throwable {
    try {
      if (checkCall(receiver, arg)) {
        return ((Float) receiver).doubleValue() + ((Float) arg).doubleValue();
      }
    }
    catch (ClassCastException e) {//
    }
    return super.call(receiver, arg);
  }
}

代码示例来源:origin: apache/storm

@SuppressWarnings("unchecked")
private static Object normalizeConfValue(Object obj) {
  if (obj instanceof Map) {
    return normalizeConf((Map<String, Object>) obj);
  } else if (obj instanceof Collection) {
    List<Object> confList = new ArrayList<>((Collection<Object>) obj);
    for (int i = 0; i < confList.size(); i++) {
      Object val = confList.get(i);
      confList.set(i, normalizeConfValue(val));
    }
    return confList;
  } else if (obj instanceof Integer) {
    return ((Number) obj).longValue();
  } else if (obj instanceof Float) {
    return ((Float) obj).doubleValue();
  } else {
    return obj;
  }
}

代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl

/**
 * Alternate factory method that will handle wrapper value, which may
 * be null.
 * Due to possibility of null, returning type is not guaranteed to be
 * {@link NumericNode}, but just {@link ValueNode}.
 * 
 * @since 1.9
 */
public ValueNode numberNode(Float value) {
  return (value == null) ? nullNode() : DoubleNode.valueOf(value.doubleValue());
}

代码示例来源:origin: org.codehaus.groovy/groovy

public final Object call(Object receiver, Object arg) throws Throwable {
    try {
      if (checkCall(receiver, arg)) {
        return ((Integer) receiver).doubleValue() / ((Float) arg).doubleValue();
      }
    }
    catch (ClassCastException e) {//
    }
    return super.call(receiver, arg);
  }
}

代码示例来源:origin: org.codehaus.groovy/groovy

public final Object call(Object receiver, Object arg) throws Throwable {
    try {
      if (checkCall(receiver, arg)) {
        return ((Integer) receiver).doubleValue() * ((Float) arg).doubleValue();
      }
    }
    catch (ClassCastException e) {//
    }
    return super.call(receiver, arg);
  }
}

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

public Double getDoubleProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
 Object value = doGetProperty(key);
 if (value == null) {
   return Double.valueOf(null);
 } else if (value instanceof Float) {
   return ((Float) value).doubleValue();
 } else if (value instanceof Double) {
   return (Double) value;
 } else if (value instanceof SimpleString) {
   return Double.parseDouble(((SimpleString) value).toString());
 }
 throw new ActiveMQPropertyConversionException("Invalid conversion: " + key);
}

代码示例来源:origin: springside/springside4

private String format(Number o) {
  if (o instanceof Float) {
    return format(((Float) o).doubleValue());
  } else if (o instanceof Double) {
    return format(((Double) o).doubleValue());
  } else if (o instanceof Short) {
    return format(((Short) o).longValue());
  } else if (o instanceof Integer) {
    return format(((Integer) o).longValue());
  } else if (o instanceof Long) {
    return format(((Long) o).longValue());
  }
  return null;
}

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

private void validateFilteredAggs(
   FilteredAggregatorFactory factory,
   float[] values,
   TestFloatColumnSelector selector
 )
 {
  FilteredAggregator agg = (FilteredAggregator) factory.factorize(
    makeColumnSelector(selector)
  );

  double expectedFirst = new Float(values[0]).doubleValue();
  double expectedSecond = new Float(values[1]).doubleValue() + expectedFirst;
  double expectedThird = expectedSecond;

  assertValues(agg, selector, expectedFirst, expectedSecond, expectedThird);
 }
}

代码示例来源:origin: CalebFenton/simplify

@Test
public void canFloatToDouble() {
  Float value = 11204.0345F;
  when(item.getValue()).thenReturn(value);
  when(item.getType()).thenReturn("F");
  when(instruction.getOpcode()).thenReturn(Opcode.FLOAT_TO_DOUBLE);
  op = (UnaryMathOp) opFactory.create(location, addressToLocation, vm);
  op.execute(node, mState);
  verify(mState, times(1)).assignRegister(eq(REGISTER_A), eq(new HeapItem(value.doubleValue(), "D")));
}

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

@Test
public void testAggregate()
{
 final float[] values = {0.15f, 0.27f};
 final TestFloatColumnSelector selector = new TestFloatColumnSelector(values);
 FilteredAggregatorFactory factory = new FilteredAggregatorFactory(
   new DoubleSumAggregatorFactory("billy", "value"),
   new SelectorDimFilter("dim", "a", null)
 );
 FilteredAggregator agg = (FilteredAggregator) factory.factorize(makeColumnSelector(selector));
 double expectedFirst = new Float(values[0]).doubleValue();
 double expectedSecond = new Float(values[1]).doubleValue() + expectedFirst;
 double expectedThird = expectedSecond;
 assertValues(agg, selector, expectedFirst, expectedSecond, expectedThird);
}

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

@Test
public void testAggregateWithOrFilter()
{
 final float[] values = {0.15f, 0.27f, 0.14f};
 final TestFloatColumnSelector selector = new TestFloatColumnSelector(values);
 FilteredAggregatorFactory factory = new FilteredAggregatorFactory(
   new DoubleSumAggregatorFactory("billy", "value"),
   new OrDimFilter(Lists.newArrayList(new SelectorDimFilter("dim", "a", null), new SelectorDimFilter("dim", "b", null)))
 );
 FilteredAggregator agg = (FilteredAggregator) factory.factorize(
   makeColumnSelector(selector)
 );
 double expectedFirst = new Float(values[0]).doubleValue();
 double expectedSecond = new Float(values[1]).doubleValue() + expectedFirst;
 double expectedThird = expectedSecond + new Float(values[2]).doubleValue();
 assertValues(agg, selector, expectedFirst, expectedSecond, expectedThird);
}

相关文章