ResultSet object as a float in the Java programming language.
352173
@Override
    public float getFloat(int columnIndex) throws SQLException {
        checkColumnBounds(columnIndex);
        try {
            final VoltType type = table.getColumnType(columnIndex - 1);
            Double doubleValue = null;
            switch(type) {
            case TINYINT:
                doubleValue = new Double(table.getLong(columnIndex - 1));
                break;
            case SMALLINT:
                doubleValue = new Double(table.getLong(columnIndex - 1));
                break;
            case INTEGER:
                doubleValue = new Double(table.getLong(columnIndex - 1));
                break;
            case BIGINT:
                doubleValue = new Double(table.getLong(columnIndex - 1));
                break;
            case FLOAT:
                doubleValue = new Double(table.getDouble(columnIndex - 1));
                break;
            case DECIMAL:
                doubleValue = table.getDecimalAsBigDecimal(columnIndex - 1).doubleValue();
                break;
            default:
                throw new IllegalArgumentException("Cannot get float value for column type '" + type + "'");
            }

            if (table.wasNull()) {
                doubleValue = new Double(0);
            } else if (Math.abs(doubleValue) > new Double(Float.MAX_VALUE)) {
                throw new SQLException("Value out of float range");
            }
            return doubleValue.floatValue();
        } catch (Exception x) {
            throw SQLError.get(x);
        }
    }
1195158
private final float getJavaVersionAsFloat() {
		if (JAVA_VERSION == null) {
			return 0f;
		}

		String str = JAVA_VERSION.substring(0, 3);

		if (JAVA_VERSION.length() >= 5) {
			str = str + JAVA_VERSION.substring(4, 5);
		}

		return Float.parseFloat(str);
	}
1310926
public float getInternalFloat(ColumnInformation columnInfo) throws SQLException {
    if (lastValueWasNull()) {
      return 0;
    }

    switch (columnInfo.getColumnType()) {
      case BIT:
        return parseBit();
      case TINYINT:
      case SMALLINT:
      case YEAR:
      case INTEGER:
      case MEDIUMINT:
      case FLOAT:
      case DOUBLE:
      case DECIMAL:
      case VARSTRING:
      case VARCHAR:
      case STRING:
      case OLDDECIMAL:
      case BIGINT:
        try {
          return Float.valueOf(new String(buf, pos, length, StandardCharsets.UTF_8));
        } catch (NumberFormatException nfe) {
          SQLException sqlException = new SQLException("Incorrect format \""
              + new String(buf, pos, length, StandardCharsets.UTF_8)
              + "\" for getFloat for data field with type " + columnInfo.getColumnType()
              .getJavaTypeName(), "22003", 1264);
          //noinspection UnnecessaryInitCause
          sqlException.initCause(nfe);
          throw sqlException;
        }
      default:
        throw new SQLException(
            "getFloat not available for data field type " + columnInfo.getColumnType()
                .getJavaTypeName());
    }
  }
849497
static Integer convertToInt(SessionInterface session, Object a, int type) {

        int value;

        if (a instanceof Integer) {
            if (type == Types.SQL_INTEGER) {
                return (Integer) a;
            }

            value = ((Integer) a).intValue();
        } else if (a instanceof Long) {
            long temp = ((Long) a).longValue();

            if (Integer.MAX_VALUE < temp || temp < Integer.MIN_VALUE) {
                throw Error.error(ErrorCode.X_22003);
            }

            value = (int) temp;
        } else if (a instanceof BigDecimal) {
            BigDecimal bd = ((BigDecimal) a);

            if (bd.compareTo(MAX_INT) > 0 || bd.compareTo(MIN_INT) < 0) {
                throw Error.error(ErrorCode.X_22003);
            }

            value = bd.intValue();
        } else if (a instanceof Double || a instanceof Float) {
            double d = ((Number) a).doubleValue();

            if (session instanceof Session) {
                if (!((Session) session).database.sqlConvertTruncate) {
                    d = java.lang.Math.rint(d);
                }
            }

            if (Double.isInfinite(d) || Double.isNaN(d)
                    || d >= (double) Integer.MAX_VALUE + 1
                    || d <= (double) Integer.MIN_VALUE - 1) {
                throw Error.error(ErrorCode.X_22003);
            }

            value = (int) d;
        } else {
            throw Error.error(ErrorCode.X_42561);
        }

        if (type == Types.TINYINT) {
            if (Byte.MAX_VALUE < value || value < Byte.MIN_VALUE) {
                throw Error.error(ErrorCode.X_22003);
            }
        } else if (type == Types.SQL_SMALLINT) {
            if (Short.MAX_VALUE < value || value < Short.MIN_VALUE) {
                throw Error.error(ErrorCode.X_22003);
            }
        }

        return Integer.valueOf(value);
    }
765521
def get_as_nullable_float(self, key):
        
        value = self.get(key)
        return FloatConverter.to_nullable_float(value)
268087
public static Float getFloat(Map<?, ?> map, Object key) {
		return get(map, key, Float.class);
	}
102058
public float getFloat(String key, float def) {
        Object tmp = objectMap.get(key);
        return tmp != null && tmp instanceof Number ? ((Number) tmp)
                .floatValue() : def;
    }
360660
public void put(String key, Float value) {
		if (this.compiledStatement != null) {
			if (value == null) {
				this.compiledStatement.bindNull(compiledStatementBindIndex++);
			} else {
				this.compiledStatement.bindDouble(compiledStatementBindIndex++, (float) value);
			}
		} else if (values != null) {
			values.put(key, value);
			return;
		}

		names.add(key);
		// values.put(key, value);
		args.add(value);
		valueType.add(ParamType.FLOAT);
	}
722824
public static Table read(ResultSet resultSet) throws SQLException {

        ResultSetMetaData metaData = resultSet.getMetaData();
        Table table = Table.create();

        // Setup the columns and add to the table
        for (int i = 1; i <= metaData.getColumnCount(); i++) {
            String name = metaData.getColumnName(i);
            int columnType = metaData.getColumnType(i);
            ColumnType type = SQL_TYPE_TO_TABLESAW_TYPE.get(columnType);
            // Try to improve on the initial type assigned to 'type' to minimize size/space of type needed.
            // For all generic numeric columns inspect closer, checking the precision and 
            // scale to more accurately determine the appropriate java type to use.
            if (columnType == Types.NUMERIC || columnType == Types.DECIMAL) {
                int s = metaData.getScale(i);
                // When scale is 0 then column is a type of integer
                if (s == 0) {
                    int p = metaData.getPrecision(i);
/* Mapping to java integer types based on integer precision defined:

Java type           TypeMinVal              TypeMaxVal          p               MaxIntVal
-----------------------------------------------------------------------------------------
byte, Byte:         -128                    127                 NUMBER(2)       99
short, Short:       -32768                  32767               NUMBER(4)       9_999
int, Integer:       -2147483648             2147483647          NUMBER(9)       999_999_999 
long, Long:         -9223372036854775808    9223372036854775807 NUMBER(18)      999_999_999_999_999_999

*/
                    // Start with SHORT (since ColumnType.BYTE isn't supported yet)
                    // and find the smallest java integer type that fits
                    if (p <= 4) {
                        type = ShortColumnType.instance();
                    } else if (p <= 9) {
                        type = ColumnType.INTEGER;
                    } else if (p <= 18) {
                        type = ColumnType.LONG;
                    }
                } else { // s is not zero, so a decimal value is expected. First try float, then double
                    if (s <= 7) {
                        type = ColumnType.FLOAT;
                    } else if (s <= 16) {
                        type = ColumnType.DOUBLE;
                    }
                }
            }
            Preconditions.checkState(type != null,
                    "No column type found for %s as specified for column %s", metaData.getColumnType(i), name);

            Column<?> newColumn = type.create(name);
            table.addColumns(newColumn);
        }

        // Add the rows
        while (resultSet.next()) {
            for (int i = 1; i <= metaData.getColumnCount(); i++) {
                Column<?> column = table.column(i - 1); // subtract 1 because results sets originate at 1 not 0
                if (column instanceof ShortColumn) {
                    column.appendObj(resultSet.getShort(i));
                } else if (column instanceof IntColumn) {
                    column.appendObj(resultSet.getInt(i));
                } else if (column instanceof LongColumn) {
                    column.appendObj(resultSet.getLong(i));
                } else if (column instanceof FloatColumn) {
                    column.appendObj(resultSet.getFloat(i));
                } else if (column instanceof DoubleColumn) {
                    column.appendObj(resultSet.getDouble(i));
                } else {
                    column.appendObj(resultSet.getObject(i));
                }
            }
        }
        return table;
    }
715268
public static <T, E extends Exception> FloatList mapToFloat(final Collection<? extends T> c, final int fromIndex, final int toIndex,
            final Try.ToFloatFunction<? super T, E> func) throws E {
        checkFromToIndex(fromIndex, toIndex, size(c));
        N.checkArgNotNull(func);

        if (N.isNullOrEmpty(c) && fromIndex == 0 && toIndex == 0) {
            return new FloatList();
        }

        final FloatList result = new FloatList(toIndex - fromIndex);

        if (c instanceof List && c instanceof RandomAccess) {
            final List<T> list = (List<T>) c;

            for (int i = fromIndex; i < toIndex; i++) {
                result.add(func.applyAsFloat(list.get(i)));
            }
        } else {
            int idx = 0;

            for (T e : c) {
                if (idx++ < fromIndex) {
                    continue;
                }

                result.add(func.applyAsFloat(e));

                if (idx >= toIndex) {
                    break;
                }
            }
        }

        return result;
    }
231449
private Object oracleGetValue(ResultSet rsltset, BackedSession s) {
        Object tmp = null;
        try {
            long startTime = System.currentTimeMillis();
            long readSize = 0;
            BufferedInputStream bis = null;
            ByteArrayInputStream bais = null;
            byte[] b = rsltset.getBytes(smallCol);
            if (b == null) {
                if (!_smc.isUseOracleBlob()) {
                    // not using blob, use getBytes to get data from medium
                    b = rsltset.getBytes(medCol);
                } else { // using blob, get from Blob column
                    Blob blob = rsltset.getBlob(medCol);
                    if (blob != null) {
                        bis = new BufferedInputStream(blob.getBinaryStream());
                        readSize = blob.length();
                    }
                }
            }
            if (b != null && b.length > 0) { // got data from small or non-Blob medium
                                             // convert to BufferedInputStream
                readSize = b.length;
                bais = new ByteArrayInputStream(b);
                bis = new BufferedInputStream(bais);
            }

            if (bis != null) { // we successfully retrieved some data
                try {
                    tmp = ((DatabaseStore) getIStore()).getLoader().loadObject(bis);
                } catch (ClassNotFoundException ce) {

                    com.ibm.ws.ffdc.FFDCFilter.processException(ce, "com.ibm.ws.session.store.db.DatabaseHashMap.oracleGetValue", "2321", s);
                    LoggingUtil.SESSION_LOGGER_WAS.logp(Level.SEVERE, methodClassName, methodNames[ORACLE_GET_VALUE], "BackedHashtable.classNotFoundError");
                    LoggingUtil.SESSION_LOGGER_WAS.logp(Level.SEVERE, methodClassName, methodNames[ORACLE_GET_VALUE], "CommonMessage.sessionid", s.getId());
                    LoggingUtil.SESSION_LOGGER_WAS.logp(Level.SEVERE, methodClassName, methodNames[ORACLE_GET_VALUE], "CommonMessage.exception", ce);
                }
                bis.close();
                if (bais != null)
                    bais.close();
                SessionStatistics pmiStats = _iStore.getSessionStatistics();
                if (pmiStats != null) {
                    pmiStats.readTimes(readSize, System.currentTimeMillis() - startTime);
                }
            }
        } catch (Throwable e) {
            com.ibm.ws.ffdc.FFDCFilter.processException(e, "com.ibm.ws.session.store.db.DatabaseHashMap.oracleGetValue", "2334", s);
            LoggingUtil.SESSION_LOGGER_WAS.logp(Level.SEVERE, methodClassName, methodNames[ORACLE_GET_VALUE], "DatabaseHashMap.oracleGetValueError");
            LoggingUtil.SESSION_LOGGER_WAS.logp(Level.SEVERE, methodClassName, methodNames[ORACLE_GET_VALUE], "CommonMessage.exception", e);
        }
        return tmp;
    }
77307
@CheckForNull
  public Float getFloat(String key) {
    String value = getString(key);
    if (StringUtils.isNotEmpty(value)) {
      try {
        return Float.valueOf(value);
      } catch (NumberFormatException e) {
        throw new IllegalStateException(String.format("The property '%s' is not a float value", key));
      }
    }
    return null;
  }
74337
static
	private Float toFloat(Object value){

		if(value instanceof Float){
			return (Float)value;
		} else

		if(value instanceof Double){
			Number number = (Number)value;

			return toFloat(number.floatValue());
		} else

		if((value instanceof Long) || (value instanceof Integer) || (value instanceof Short) || (value instanceof Byte)){
			Number number = (Number)value;

			return toFloat(number.floatValue());
		} else

		if(value instanceof Boolean){
			Boolean flag = (Boolean)value;

			return (flag.booleanValue() ? Numbers.FLOAT_ONE : Numbers.FLOAT_ZERO);
		} else

		if((value instanceof DaysSinceDate) || (value instanceof SecondsSinceDate) || (value instanceof SecondsSinceMidnight)){
			Number number = (Number)value;

			return toFloat(number.floatValue());
		}

		throw new TypeCheckException(DataType.FLOAT, value);
	}
610408
public static float toFloat(final Object value) {
		if (value instanceof Float) {
			return (float) value;
		}
		if (value == null) {
			return 0;
		}
		return new Float(value.toString());
	}
840464
public static Object toPrimitiveFloatArray(List<?> values)
    {
        float[] array = new float[values.size()];
        int cursor = 0;
        
        for(Object o : values)
        {
            array[cursor] = (Float) o;
            cursor ++;
        }
        return array;
    }
171989
public float getFloat(int key)
    {
        Object value = map.get(key);
        if (!(value instanceof Float))
        {
            return 0.0f;
        }
        Float result = (Float)value;
        return result;
    }
633689
@Override
    public Object map(Object input) {
        List<Float> row = (List<Float>) input;
        switch (mathOp) {
            case Add:
                float sum = 0f;
                for (Float w : row)
                    sum += w;
                return sum;
            case Subtract:
                return row.get(0) - row.get(1);
            case Multiply:
                float product = 1.0f;
                for (Float w : row)
                    product *= w;
                return product;
            case Divide:
                return row.get(0) / row.get(1);
            case Modulus:
                return row.get(0) % row.get(1);
            case ReverseSubtract:
            case ReverseDivide:
            case ScalarMin:
            case ScalarMax:
            default:
                throw new RuntimeException("Invalid mathOp: " + mathOp); //Should never happen
        }
    }