List of usage examples for java.lang Double floatValue
public float floatValue()
From source file:Main.java
public static void main(String[] args) { Double doubleObject = new Double("10.01"); float f = doubleObject.floatValue(); System.out.println("float" + f); }
From source file:Main.java
public static void main(String[] args) { Integer intObj = Integer.valueOf(100); // Gets byte from Integer byte b = intObj.byteValue(); // Gets double from Integer double dd = intObj.doubleValue(); System.out.println("intObj = " + intObj); System.out.println("byte from intObj = " + b); System.out.println("double from intObj = " + dd); // Creates a Double object Double doubleObj = Double.valueOf("123.45"); // Gets different types of primitive values from Double double d = doubleObj.doubleValue(); float f = doubleObj.floatValue(); int i = doubleObj.intValue(); long l = doubleObj.longValue(); System.out.println("doubleObj = " + doubleObj); System.out.println("double from doubleObj = " + d); System.out.println("float from doubleObj = " + f); System.out.println("int from doubleObj = " + i); System.out.println("long from doubleObj = " + l); }
From source file:Main.java
public static void main(String[] args) { Double dObj = new Double("10.50"); byte b = dObj.byteValue(); System.out.println(b);// w w w .ja v a2 s .co m short s = dObj.shortValue(); System.out.println(s); int i = dObj.intValue(); System.out.println(i); float f = dObj.floatValue(); System.out.println(f); double d = dObj.doubleValue(); System.out.println(d); }
From source file:ome.util.Validator.java
public static Validation validate(ImagingEnvironment imageEnvironment) { Validation v = Validation.VALID();/* www .j a v a 2s . co m*/ Double co2 = imageEnvironment.getCo2percent(); if (null != co2 && (co2.floatValue() < 0 || co2.floatValue() > 1)) { v.invalidate("ImageEnvironment.co2percent must be between 0 and 1"); } Double humidity = imageEnvironment.getHumidity(); if (null != humidity && (humidity.floatValue() < 0 || humidity.floatValue() > 1)) { v.invalidate("ImageEnvironment.humidity must be between 0 and 1"); } return v; }
From source file:org.openehr.adl.util.AdlUtils.java
@Nullable public static Float doubleToFloat(@Nullable Double d) { return d != null ? d.floatValue() : null; }
From source file:Main.java
public static int getTempColor(Double temp) { float hue;// ww w. j a v a2 s.c o m if (temp >= TEMP_UPPER) { hue = BAD; } else if (temp <= TEMP_LOWER) { hue = GOOD; } else { hue = GOOD - (temp.floatValue() - TEMP_LOWER) / (TEMP_UPPER - TEMP_LOWER) * (GOOD - BAD) + BAD; } return Color.HSVToColor(new float[] { hue, SATURATION, VALUE }); }
From source file:Main.java
public static int GetVoltsColor(Double volts) { float hue;/*from ww w . ja va2 s . c o m*/ if (volts >= VOLTAGE_UPPER) { hue = GOOD; } else if (volts <= VOLTAGE_LOWER) { hue = BAD; } else { hue = (volts.floatValue() - VOLTAGE_LOWER) / (VOLTAGE_UPPER - VOLTAGE_LOWER) * (GOOD - BAD) + BAD; } return Color.HSVToColor(new float[] { hue, SATURATION, VALUE }); }
From source file:com.sparkplatform.ui.ListingFormatter.java
private static String formatPriceShort(Double price) { if (price == null || price.floatValue() <= 0) return null; StringBuilder builder = new StringBuilder(); int trimmedPrice = (int) (price.floatValue() / 1000.0); if (trimmedPrice < 1000) { currencyFormat.setMaximumFractionDigits(0); builder.append(currencyFormat.format(trimmedPrice)); builder.append("K"); } else {// ww w.j a v a2 s. com float trimmedPriceFloat = (float) (trimmedPrice / 1000.0); if (trimmedPrice % 1000 == 0) currencyFormat.setMaximumFractionDigits(0); else currencyFormat.setMaximumFractionDigits(2); builder.append(currencyFormat.format(trimmedPriceFloat)); builder.append("M"); } return builder.toString(); }
From source file:Main.java
public static int GetRPMColor(Double rpm) { float hue;//from ww w.j a v a 2 s . c om if (rpm >= RPM_HIGH || rpm <= RPM_LOW) { hue = BAD; } else if (rpm == RPM_ECO) { hue = GOOD; } else if (rpm < RPM_ECO) { hue = (rpm.floatValue() - RPM_LOW) / (RPM_ECO - RPM_LOW) * (GOOD - BAD) + BAD; } else { hue = GOOD - (rpm.floatValue() - RPM_ECO) / (RPM_HIGH - RPM_ECO) * (GOOD - BAD) + BAD; } return Color.HSVToColor(new float[] { hue, SATURATION, VALUE }); }
From source file:Main.java
public static int GetAmpsColor(Double amps) { float hue;//from w w w. j a v a 2 s .c o m if (amps >= AMPS_HIGH || amps <= AMPS_LOW) { hue = BAD; } else if (amps == AMPS_ECO) { hue = GOOD; } else if (amps < AMPS_ECO) { hue = (amps.floatValue() - AMPS_LOW) / (AMPS_ECO - AMPS_LOW) * (GOOD - BAD) + BAD; } else { hue = GOOD - (amps.floatValue() - AMPS_ECO) / (AMPS_HIGH - AMPS_ECO) * (GOOD - BAD) + BAD; } return Color.HSVToColor(new float[] { hue, SATURATION, VALUE }); }