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

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

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

Double.shortValue介绍

[英]Returns the value of this Double as a short (by casting to a short).
[中]将此双精度的值作为短值返回(通过转换为短值)。

代码示例

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

public Short toShort(Double self) {
  return self.shortValue();
}

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

public short evaluate(String xml, String path) {
  return xpath.evalNumber(xml, path).shortValue();
 }
}

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

public short evaluate(String xml, String path) {
  return xpath.evalNumber(xml, path).shortValue();
 }
}

代码示例来源:origin: hibernate/hibernate-orm

return (X) Short.valueOf( value.shortValue() );

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

case Types.SMALLINT:
case Types.TINYINT:
  return new PGShort( new Short( val.shortValue() ) );
case Types.VARCHAR:
case Types.LONGVARCHAR:

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

@Test
public void testStatement() {
  OutParameters ret = h.createCall("? = CALL TO_DEGREES(?)")
      .registerOutParameter(0, Types.DOUBLE)
      .bind(1, 100.0d)
      .invoke();
  Double expected = Math.toDegrees(100.0d);
  assertThat(ret.getDouble(0)).isEqualTo(expected, Offset.offset(0.001));
  assertThat(ret.getLong(0).longValue()).isEqualTo(expected.longValue());
  assertThat(ret.getShort(0).shortValue()).isEqualTo(expected.shortValue());
  assertThat(ret.getInt(0).intValue()).isEqualTo(expected.intValue());
  assertThat(ret.getFloat(0).floatValue()).isEqualTo(expected.floatValue(), Offset.offset(0.001f));
  assertThatExceptionOfType(Exception.class).isThrownBy(() -> ret.getDate(1));
  assertThatExceptionOfType(Exception.class).isThrownBy(() -> ret.getDate(2));
}

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

@Test
public void testStatementWithNamedParam() {
  OutParameters ret = h.createCall(":x = CALL TO_DEGREES(:y)")
      .registerOutParameter("x", Types.DOUBLE)
      .bind("y", 100.0d)
      .invoke();
  Double expected = Math.toDegrees(100.0d);
  assertThat(ret.getDouble("x")).isEqualTo(expected, Offset.offset(0.001));
  assertThat(ret.getLong("x").longValue()).isEqualTo(expected.longValue());
  assertThat(ret.getShort("x").shortValue()).isEqualTo(expected.shortValue());
  assertThat(ret.getInt("x").intValue()).isEqualTo(expected.intValue());
  assertThat(ret.getFloat("x")).isEqualTo(expected.floatValue());
  assertThatExceptionOfType(Exception.class).isThrownBy(() -> ret.getDate("x"));
  assertThatExceptionOfType(Exception.class).isThrownBy(() -> ret.getDate("y"));
}

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

/**
 * @param value string represented numerical value
 * @return value as Short
 */
public static Short getShortValue(String value) {
  nShorts++;
  return parseDoubleUnit(value).shortValue();
}

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

private void updateUnsignedTable(Connection conn, double data) throws Exception {
  PreparedStatement stmt = conn.prepareStatement("UPSERT INTO " + testUnsignedTable + " VALUES (?, ?, ?, ?, ?, ?, ?)");
  stmt.setString(1, KEY);
  Double d = Double.valueOf(data);
  stmt.setDouble(2, d.doubleValue());
  stmt.setFloat(3, d.floatValue());
  stmt.setInt(4, d.intValue());
  stmt.setLong(5, d.longValue());
  stmt.setShort(6, d.shortValue());
  stmt.setByte(7, d.byteValue());
  stmt.executeUpdate();
  conn.commit();
}

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

private void updateSignedTable(Connection conn, double data) throws Exception {
  PreparedStatement stmt = conn.prepareStatement("UPSERT INTO " + signedTableName + " VALUES (?, ?, ?, ?, ?, ?, ?)");
  stmt.setString(1, KEY);
  Double d = Double.valueOf(data);
  stmt.setDouble(2, d.doubleValue());
  stmt.setFloat(3, d.floatValue());
  stmt.setInt(4, d.intValue());
  stmt.setLong(5, d.longValue());
  stmt.setShort(6, d.shortValue());
  stmt.setByte(7, d.byteValue());
  stmt.executeUpdate();
  conn.commit();
}

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

private void updateSignedTable(Connection conn, double data) throws Exception {
  PreparedStatement stmt = conn.prepareStatement("UPSERT INTO " + testSignedTable + " VALUES (?, ?, ?, ?, ?, ?, ?)");
  stmt.setString(1, KEY);
  Double d = Double.valueOf(data);
  stmt.setDouble(2, d.doubleValue());
  stmt.setFloat(3, d.floatValue());
  stmt.setInt(4, d.intValue());
  stmt.setLong(5, d.longValue());
  stmt.setShort(6, d.shortValue());
  stmt.setByte(7, d.byteValue());
  stmt.executeUpdate();
  conn.commit();
}

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

private void updateUnsignedTable(Connection conn, double data) throws Exception {
  PreparedStatement stmt = conn.prepareStatement("UPSERT INTO " + unsignedTableName + " VALUES (?, ?, ?, ?, ?, ?, ?)");
  stmt.setString(1, KEY);
  Double d = Double.valueOf(data);
  stmt.setDouble(2, d.doubleValue());
  stmt.setFloat(3, d.floatValue());
  stmt.setInt(4, d.intValue());
  stmt.setLong(5, d.longValue());
  stmt.setShort(6, d.shortValue());
  stmt.setByte(7, d.byteValue());
  stmt.executeUpdate();
  conn.commit();
}

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

private void updateSignedTable(Connection conn, double data) throws Exception {
  PreparedStatement stmt = conn.prepareStatement(
    "UPSERT INTO " + signedTableName + " VALUES (?, ?, ?, ?, ?, ?, ?)");
  stmt.setString(1, KEY);
  Double d = Double.valueOf(data);
  stmt.setDouble(2, d.doubleValue());
  stmt.setFloat(3, d.floatValue());
  stmt.setInt(4, d.intValue());
  stmt.setLong(5, d.longValue());
  stmt.setShort(6, d.shortValue());
  stmt.setByte(7, d.byteValue());
  stmt.executeUpdate();
  conn.commit();
}

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

private void updateUnsignedTable(Connection conn, double data) throws Exception {
  PreparedStatement stmt = conn.prepareStatement(
    "UPSERT INTO " + unsignedTableName + " VALUES (?, ?, ?, ?, ?, ?, ?)");
  stmt.setString(1, KEY);
  Double d = Double.valueOf(data);
  stmt.setDouble(2, d.doubleValue());
  stmt.setFloat(3, d.floatValue());
  stmt.setInt(4, d.intValue());
  stmt.setLong(5, d.longValue());
  stmt.setShort(6, d.shortValue());
  stmt.setByte(7, d.byteValue());
  stmt.executeUpdate();
  conn.commit();
}

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

private void updateTableSpec(Connection conn, double data, String tableName) throws Exception {
  PreparedStatement stmt =
      conn.prepareStatement("UPSERT INTO " + tableName + " VALUES (?, ?, ?, ?, ?, ?, ?)");
  stmt.setString(1, KEY);
  Double d = Double.valueOf(data);
  stmt.setDouble(2, d.doubleValue());
  stmt.setFloat(3, d.floatValue());
  stmt.setInt(4, d.intValue());
  stmt.setLong(5, d.longValue());
  stmt.setShort(6, d.shortValue());
  stmt.setByte(7, d.byteValue());
  stmt.executeUpdate();
  conn.commit();
}

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

private void updateUnsignedTable(Connection conn, double data) throws Exception {
  PreparedStatement stmt = conn.prepareStatement(
    "UPSERT INTO " + unsignedTableName + " VALUES (?, ?, ?, ?, ?, ?, ?)");
  stmt.setString(1, KEY);
  Double d = Double.valueOf(data);
  stmt.setDouble(2, d.doubleValue());
  stmt.setFloat(3, d.floatValue());
  stmt.setInt(4, d.intValue());
  stmt.setLong(5, d.longValue());
  stmt.setShort(6, d.shortValue());
  stmt.setByte(7, d.byteValue());
  stmt.executeUpdate();
  conn.commit();
}

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

private void updateSignedTable(Connection conn, double data) throws Exception {
  PreparedStatement stmt = conn.prepareStatement("UPSERT INTO " + TABLE_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
  stmt.setString(1, KEY);
  Double d = Double.valueOf(data);
  stmt.setBigDecimal(2, BigDecimal.valueOf(data));
  stmt.setDouble(3, d.doubleValue());
  stmt.setFloat(4, d.floatValue());
  stmt.setInt(5, d.intValue());
  stmt.setLong(6, d.longValue());
  stmt.setShort(7, d.shortValue());
  stmt.setByte(8, d.byteValue());
  stmt.executeUpdate();
  conn.commit();
}

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

private void updateTableSpec(Connection conn, double data, String tableName) throws Exception {
  PreparedStatement stmt =
      conn.prepareStatement("UPSERT INTO " + tableName + " VALUES (?, ?, ?, ?, ?, ?, ?)");
  stmt.setString(1, KEY);
  Double d = Double.valueOf(data);
  stmt.setDouble(2, d.doubleValue());
  stmt.setFloat(3, d.floatValue());
  stmt.setInt(4, d.intValue());
  stmt.setLong(5, d.longValue());
  stmt.setShort(6, d.shortValue());
  stmt.setByte(7, d.byteValue());
  stmt.executeUpdate();
  conn.commit();
}

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

private void testUnsignedNumberSpec(Connection conn, double data) throws Exception {
  updateUnsignedTable(conn, data);
  ResultSet rs = conn.createStatement().executeQuery("SELECT EXP(doub),EXP(fl),EXP(inte),EXP(lon),EXP(smalli),EXP(tinyi) FROM " + unsignedTableName);
  assertTrue(rs.next());
  Double d = Double.valueOf(data);
  assertTrue(Math.abs(rs.getDouble(1) - Math.exp(d.doubleValue())) < ZERO);
  assertTrue(Math.abs(rs.getDouble(2) - Math.exp(d.floatValue())) < ZERO);
  assertTrue(Math.abs(rs.getDouble(3) - Math.exp(d.intValue())) < ZERO);
  assertTrue(Math.abs(rs.getDouble(4) - Math.exp(d.longValue())) < ZERO);
  assertTrue(Math.abs(rs.getDouble(5) - Math.exp(d.shortValue())) < ZERO);
  assertTrue(Math.abs(rs.getDouble(6) - Math.exp(d.byteValue())) < ZERO);
  assertTrue(!rs.next());
}

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

private void testSignedNumberSpec(Connection conn, double data) throws Exception {
  updateSignedTable(conn, data);
  ResultSet rs = conn.createStatement().executeQuery("SELECT EXP(doub),EXP(fl),EXP(inte),EXP(lon),EXP(smalli),EXP(tinyi) FROM " + signedTableName);
  assertTrue(rs.next());
  Double d = Double.valueOf(data);
  assertTrue(Math.abs(rs.getDouble(1) - Math.exp(d.doubleValue())) < ZERO);
  assertTrue(Math.abs(rs.getDouble(2) - Math.exp(d.floatValue())) < ZERO);
  assertTrue(Math.abs(rs.getDouble(3) - Math.exp(d.intValue())) < ZERO);
  assertTrue(Math.abs(rs.getDouble(4) - Math.exp(d.longValue())) < ZERO);
  assertTrue(Math.abs(rs.getDouble(5) - Math.exp(d.shortValue())) < ZERO);
  assertTrue(Math.abs(rs.getDouble(6) - Math.exp(d.byteValue())) < ZERO);
  assertTrue(!rs.next());
}

相关文章