public static double getTPS(final CallSnapshot begin, final CallSnapshot end) { long total = end.callTimesTotal - begin.callTimesTotal; Long time = end.timestamp - begin.timestamp; double tps = total / time.doubleValue(); return tps * 1000; } }
@Override public double divideForAvg(Long l1, Long l2) { return (l2 == null || l1 == null) ? Double.NaN : (l1.doubleValue() / l2 .doubleValue()); }
public Double toDouble(Long self) { return self.doubleValue(); }
@Override public Double toDouble(Object value) { return ((Long) value).doubleValue(); }
@Override public double divideForAvg(Double d1, Long l2) { return (l2 == null || d1 == null) ? Double.NaN : (d1.doubleValue() / l2 .doubleValue()); }
@Override public double divideForAvg(BigDecimal bd1, Long l2) { return (l2 == null || bd1 == null) ? Double.NaN : (bd1.doubleValue() / l2 .doubleValue()); }
Long l = new Long(15552451L); double d = l.doubleValue();
public MeanReducerState reduce(MeanReducerState acc, Object input) { acc.count++; if (input instanceof Double) { acc.sum += (Double) input; } else if (input instanceof Long) { acc.sum += ((Long) input).doubleValue(); } else if (input instanceof Integer) { acc.sum += ((Integer) input).doubleValue(); } else { throw new RuntimeException( "MeanReducer::reduce called with unsupported input type `" + input.getClass() + "`. Supported types are Double, Long, Integer."); } return acc; }
public MeanReducerState reduce(MeanReducerState acc, Object input) { acc.count++; if (input instanceof Double) { acc.sum += (Double) input; } else if (input instanceof Long) { acc.sum += ((Long) input).doubleValue(); } else if (input instanceof Integer) { acc.sum += ((Integer) input).doubleValue(); } else { throw new RuntimeException("MeanReducer::reduce called with unsupported input type `" + input.getClass() + "`. Supported types are Double, Long, Integer."); } return acc; }
public static Number add(Long first, double second) { double sum = first.doubleValue() + second; if (Float.MAX_VALUE >= sum && Float.MIN_VALUE <= sum) return Float.valueOf((float) sum); return Double.valueOf(sum); }
public static double getNumber( Comparable o ) { // hint to the jit to do a instanceof breakdown tree if( o instanceof Double ) return ((Double)o).doubleValue(); if( o instanceof Long ) return ((Long )o).doubleValue(); if( o instanceof Number ) return ((Number)o).doubleValue(); if( o instanceof String ) { try { return Double.valueOf((String)o); } catch( Throwable t ) { } } return Double.NaN; } public static double getBoolean( HashMap<String,Comparable> row, String s ) {
@Override public double call(ApacheAccessLog log) { return new Long(log.getContentSize()).doubleValue(); } }
@Override public Double getNumber( Object object ) throws KettleValueException { Long l = getInteger( object ); if ( l == null ) { return null; } return l.doubleValue(); }
@Override public Double getNumber( Object object ) throws KettleValueException { Timestamp timestamp = getTimestamp( object ); if ( timestamp == null ) { return null; } long ms = timestamp.getTime(); return Long.valueOf( ms ).doubleValue(); }
/** * 将long整数与小数相乘,计算结四舍五入保留整数位。 * * @param num1 数字1 * @param num2 数字2 * @return 数字相乘计算结果 */ public static int multiply(long num1, double num2) { double num1D = ((Long) num1).doubleValue(); return multiply(num1D, num2); }
/** * 将long整数与小数相乘,计算结四舍五入保留整数位。 * * @param num1 数字1 * @param num2 数字2 * @return 数字相乘计算结果 */ public static int multiply(long num1, double num2) { double num1D = ((Long) num1).doubleValue(); return multiply(num1D, num2); }
@Override public double getDoubleValue(int dictId) { return ((Long) get(dictId)).doubleValue(); }
static OptionalDouble toStatsRepresentation(FunctionRegistry functionRegistry, ConnectorSession session, Type type, Object value) { if (convertibleToDoubleWithCast(type)) { InterpretedFunctionInvoker functionInvoker = new InterpretedFunctionInvoker(functionRegistry); Signature castSignature = functionRegistry.getCoercion(type, DoubleType.DOUBLE); return OptionalDouble.of((double) functionInvoker.invoke(castSignature, session, singletonList(value))); } if (DateType.DATE.equals(type)) { return OptionalDouble.of(((Long) value).doubleValue()); } return OptionalDouble.empty(); }
@Test public void getClaimAsInstantWhenDoubleTypeSecondsThenReturnInstant() { Instant expectedClaimValue = Instant.now(); String claimName = "doubleSeconds"; this.claims.put(claimName, Long.valueOf(expectedClaimValue.getEpochSecond()).doubleValue()); assertThat(this.claimAccessor.getClaimAsInstant(claimName)).isBetween( expectedClaimValue.minusSeconds(1), expectedClaimValue.plusSeconds(1)); }
@Test public void canLongToDouble() { Long value = 112040345L; when(item.getValue()).thenReturn(value); when(item.getType()).thenReturn("J"); when(instruction.getOpcode()).thenReturn(Opcode.LONG_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"))); }