@Override public Long toLong(Object value) { return ((Float) value).longValue(); }
public Long toLong(Float self) { return self.longValue(); }
public static Number add(Float first, BigDecimal second) { return second.add(BigDecimal.valueOf(first.longValue())); }
public static Number add(Float first, BigInteger second) { return second.add(BigInteger.valueOf(first.longValue())); }
@Override public long getLongValue(int dictId) { return ((Float) get(dictId)).longValue(); }
@Override public long getLongValue(int dictId) { return ((Float) get(dictId)).longValue(); }
public Long convert(Object src) { if(src == null){ return null; } if(Long.class.isAssignableFrom(src.getClass())){ return (Long) src; } else if (Integer.class.isAssignableFrom(src.getClass())) { return ((Integer) src).longValue(); } else if (Double.class.isAssignableFrom(src.getClass())) { return ((Double) src).longValue(); } else if (BigDecimal.class.isAssignableFrom(src.getClass())) { return ((BigDecimal) src).longValue(); } else if (Float.class.isAssignableFrom(src.getClass())) { return ((Float) src).longValue(); } else if (String.class.isAssignableFrom(src.getClass())) { return Long.valueOf(src.toString()); } throw new MappingException("can not map a " + src.getClass() + " to " + Long.class.getName()); } }
resultValue = typedValue.intValue(); } else if (opName.endsWith("long")) { resultValue = typedValue.longValue();
return new PGLong(new Long( val.longValue() )); case Types.INTEGER: return new PGInteger(new Integer( val.intValue() ) );
@Test public void canFloatToLong() { Float value = 11204.0345F; when(item.getValue()).thenReturn(value); when(item.getType()).thenReturn("F"); when(instruction.getOpcode()).thenReturn(Opcode.FLOAT_TO_LONG); op = (UnaryMathOp) opFactory.create(location, addressToLocation, vm); op.execute(node, mState); verify(mState, times(1)).assignRegister(eq(REGISTER_A), eq(new HeapItem(value.longValue(), "J"))); }
/** * Get a long named with the given key, even if it's another * type of number. * * <p>If the key does not exist or its value is not a number, * then {@code 0} will be returned.</p> * * @param key the key * @return a long */ public long asLong(String key) { Tag tag = value.get(key); if (tag instanceof ByteTag) { return ((ByteTag) tag).getValue(); } else if (tag instanceof ShortTag) { return ((ShortTag) tag).getValue(); } else if (tag instanceof IntTag) { return ((IntTag) tag).getValue(); } else if (tag instanceof LongTag) { return ((LongTag) tag).getValue(); } else if (tag instanceof FloatTag) { return ((FloatTag) tag).getValue().longValue(); } else if (tag instanceof DoubleTag) { return ((DoubleTag) tag).getValue().longValue(); } else { return 0L; } }
= new Float((new Float(labelID).floatValue() / new Float(units.size()).intValue()) * 100.0).longValue(); if (xmlLabel.stmtPercentage > maxStmtCount) { maxStmtCount = xmlLabel.stmtPercentage; = new Float((new Float(labelID).floatValue() / new Float(units.size()).floatValue()) * 100.0).longValue(); if (xmlLabel.stmtPercentage > maxStmtCount) { maxStmtCount = xmlLabel.stmtPercentage; tempLabel.stmtPercentage = new Float((new Float(tempLabel.stmtPercentage).floatValue() / new Float(maxStmtCount).floatValue()) * 100.0) .longValue();
/** * Get a long named with the given index, even if it's another * type of number. * * <p>If the index does not exist or its value is not a number, * then {@code 0} will be returned.</p> * * @param index the index * @return a long */ public long asLong(int index) { Tag tag = getIfExists(index); if (tag instanceof ByteTag) { return ((ByteTag) tag).getValue(); } else if (tag instanceof ShortTag) { return ((ShortTag) tag).getValue(); } else if (tag instanceof IntTag) { return ((IntTag) tag).getValue(); } else if (tag instanceof LongTag) { return ((LongTag) tag).getValue(); } else if (tag instanceof FloatTag) { return ((FloatTag) tag).getValue().longValue(); } else if (tag instanceof DoubleTag) { return ((DoubleTag) tag).getValue().longValue(); } else { return 0; } }
@Test public void testDoubleFirstCombiningBufferAggregator() { BufferAggregator agg = combiningAggFactory.factorizeBuffered( colSelectorFactory); ByteBuffer buffer = ByteBuffer.wrap(new byte[floatFirstAggregatorFactory.getMaxIntermediateSizeWithNulls()]); agg.init(buffer, 0); aggregate(agg, buffer, 0); aggregate(agg, buffer, 0); aggregate(agg, buffer, 0); aggregate(agg, buffer, 0); Pair<Long, Float> result = (Pair<Long, Float>) agg.get(buffer, 0); Pair<Long, Float> expected = (Pair<Long, Float>) pairs[2]; Assert.assertEquals(expected.lhs, result.lhs); Assert.assertEquals(expected.rhs, result.rhs, 0.0001); Assert.assertEquals(expected.rhs.longValue(), agg.getLong(buffer, 0)); Assert.assertEquals(expected.rhs, agg.getFloat(buffer, 0), 0.0001); }
@Test public void testDoubleLastCombiningBufferAggregator() { BufferAggregator agg = combiningAggFactory.factorizeBuffered( colSelectorFactory); ByteBuffer buffer = ByteBuffer.wrap(new byte[floatLastAggregatorFactory.getMaxIntermediateSizeWithNulls()]); agg.init(buffer, 0); aggregate(agg, buffer, 0); aggregate(agg, buffer, 0); aggregate(agg, buffer, 0); aggregate(agg, buffer, 0); Pair<Long, Float> result = (Pair<Long, Float>) agg.get(buffer, 0); Pair<Long, Float> expected = (Pair<Long, Float>) pairs[2]; Assert.assertEquals(expected.lhs, result.lhs); Assert.assertEquals(expected.rhs, result.rhs, 0.0001); Assert.assertEquals(expected.rhs.longValue(), agg.getLong(buffer, 0)); Assert.assertEquals(expected.rhs, agg.getFloat(buffer, 0), 0.0001); }
assertFunction("sign(BIGINT '" + intValue + "')", BIGINT, signum.longValue());
@Test public void testDoubleLastCombiningAggregator() { Aggregator agg = combiningAggFactory.factorize(colSelectorFactory); aggregate(agg); aggregate(agg); aggregate(agg); aggregate(agg); Pair<Long, Float> result = (Pair<Long, Float>) agg.get(); Pair<Long, Float> expected = (Pair<Long, Float>) pairs[2]; Assert.assertEquals(expected.lhs, result.lhs); Assert.assertEquals(expected.rhs, result.rhs, 0.0001); Assert.assertEquals(expected.rhs.longValue(), agg.getLong()); Assert.assertEquals(expected.rhs, agg.getFloat(), 0.0001); }
@Test public void testDoubleFirstCombiningAggregator() { Aggregator agg = combiningAggFactory.factorize(colSelectorFactory); aggregate(agg); aggregate(agg); aggregate(agg); aggregate(agg); Pair<Long, Float> result = (Pair<Long, Float>) agg.get(); Pair<Long, Float> expected = (Pair<Long, Float>) pairs[2]; Assert.assertEquals(expected.lhs, result.lhs); Assert.assertEquals(expected.rhs, result.rhs, 0.0001); Assert.assertEquals(expected.rhs.longValue(), agg.getLong()); Assert.assertEquals(expected.rhs, agg.getFloat(), 0.0001); }
public Long convert(Object src) { if(src == null){ return null; } if(Long.class.isAssignableFrom(src.getClass())){ return (Long) src; } else if (Integer.class.isAssignableFrom(src.getClass())) { return ((Integer) src).longValue(); } else if (Double.class.isAssignableFrom(src.getClass())) { return ((Double) src).longValue(); } else if (BigDecimal.class.isAssignableFrom(src.getClass())) { return ((BigDecimal) src).longValue(); } else if (Float.class.isAssignableFrom(src.getClass())) { return ((Float) src).longValue(); } else if (String.class.isAssignableFrom(src.getClass())) { return Long.valueOf(src.toString()); } throw new MappingException("can not map a " + src.getClass() + " to " + Long.class.getName()); } }