List of usage examples for java.lang Float MIN_VALUE
float MIN_VALUE
To view the source code for java.lang Float MIN_VALUE.
Click Source Link
From source file:org.broadinstitute.sting.utils.codecs.bcf2.BCF2EncoderDecoderUnitTest.java
@BeforeSuite public void before() { basicTypes.add(new BCF2TypedValue(1, BCF2Type.INT8)); basicTypes.add(new BCF2TypedValue(1000, BCF2Type.INT16)); basicTypes.add(new BCF2TypedValue(1000000, BCF2Type.INT32)); basicTypes.add(new BCF2TypedValue(1.2345e6, BCF2Type.FLOAT)); basicTypes.add(new BCF2TypedValue("A", BCF2Type.CHAR)); // small ints primitives.add(new BCF2TypedValue(0, BCF2Type.INT8)); primitives.add(new BCF2TypedValue(10, BCF2Type.INT8)); primitives.add(new BCF2TypedValue(-1, BCF2Type.INT8)); primitives.add(new BCF2TypedValue(100, BCF2Type.INT8)); primitives.add(new BCF2TypedValue(-100, BCF2Type.INT8)); primitives.add(new BCF2TypedValue(-127, BCF2Type.INT8)); // last value in range primitives.add(new BCF2TypedValue(127, BCF2Type.INT8)); // last value in range // medium ints primitives.add(new BCF2TypedValue(-1000, BCF2Type.INT16)); primitives.add(new BCF2TypedValue(1000, BCF2Type.INT16)); primitives.add(new BCF2TypedValue(-128, BCF2Type.INT16)); // first value in range primitives.add(new BCF2TypedValue(128, BCF2Type.INT16)); // first value in range primitives.add(new BCF2TypedValue(-32767, BCF2Type.INT16)); // last value in range primitives.add(new BCF2TypedValue(32767, BCF2Type.INT16)); // last value in range // larger ints primitives.add(new BCF2TypedValue(-32768, BCF2Type.INT32)); // first value in range primitives.add(new BCF2TypedValue(32768, BCF2Type.INT32)); // first value in range primitives.add(new BCF2TypedValue(-100000, BCF2Type.INT32)); primitives.add(new BCF2TypedValue(100000, BCF2Type.INT32)); primitives.add(new BCF2TypedValue(-2147483647, BCF2Type.INT32)); primitives.add(new BCF2TypedValue(2147483647, BCF2Type.INT32)); // floats//from w w w. j a v a2s. co m primitives.add(new BCF2TypedValue(0.0, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(-0.0, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(1.0, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(-1.0, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(1.1, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(-1.1, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(5.0 / 3.0, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(-5.0 / 3.0, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(1.23e3, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(1.23e6, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(1.23e9, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(1.23e12, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(1.23e15, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(-1.23e3, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(-1.23e6, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(-1.23e9, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(-1.23e12, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(-1.23e15, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(Float.MIN_VALUE, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(Float.MAX_VALUE, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(Double.NEGATIVE_INFINITY, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(Double.POSITIVE_INFINITY, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(Double.NaN, BCF2Type.FLOAT)); // strings //primitives.add(new BCF2TypedValue("", BCFType.CHAR)); <- will be null (which is right) primitives.add(new BCF2TypedValue("S", BCF2Type.CHAR)); primitives.add(new BCF2TypedValue("S2", BCF2Type.CHAR)); primitives.add(new BCF2TypedValue("12345678910", BCF2Type.CHAR)); primitives.add(new BCF2TypedValue("ABCDEFGHIJKLMNOPQRSTUVWXYZ", BCF2Type.CHAR)); primitives.add(new BCF2TypedValue( "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", BCF2Type.CHAR)); // missing values for (BCF2Type type : BCF2Type.values()) { primitives.add(new BCF2TypedValue(null, type)); } forCombinations.add(new BCF2TypedValue(10, BCF2Type.INT8)); forCombinations.add(new BCF2TypedValue(100, BCF2Type.INT8)); forCombinations.add(new BCF2TypedValue(-100, BCF2Type.INT8)); forCombinations.add(new BCF2TypedValue(-128, BCF2Type.INT16)); // first value in range forCombinations.add(new BCF2TypedValue(128, BCF2Type.INT16)); // first value in range forCombinations.add(new BCF2TypedValue(-100000, BCF2Type.INT32)); forCombinations.add(new BCF2TypedValue(100000, BCF2Type.INT32)); forCombinations.add(new BCF2TypedValue(0.0, BCF2Type.FLOAT)); forCombinations.add(new BCF2TypedValue(1.23e6, BCF2Type.FLOAT)); forCombinations.add(new BCF2TypedValue(-1.23e6, BCF2Type.FLOAT)); forCombinations.add(new BCF2TypedValue("S", BCF2Type.CHAR)); forCombinations.add(new BCF2TypedValue("ABCDEFGHIJKLMNOPQRSTUVWXYZ", BCF2Type.CHAR)); forCombinations.add(new BCF2TypedValue( "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", BCF2Type.CHAR)); // missing values for (BCF2Type type : BCF2Type.values()) { forCombinations.add(new BCF2TypedValue(null, type)); } }
From source file:org.deegree.tools.rendering.manager.buildings.PrototypeManager.java
/** * @param rqm//from ww w . j a v a2s . c om */ private RenderableQualityModel createScaledQualityModel(RenderableQualityModel rqm) { float minX = Float.MAX_VALUE; float minY = Float.MAX_VALUE; float minZ = Float.MAX_VALUE; float maxX = Float.MIN_VALUE; float maxY = Float.MIN_VALUE; float maxZ = Float.MIN_VALUE; ArrayList<RenderableQualityModelPart> qualityModelParts = rqm.getQualityModelParts(); for (RenderableQualityModelPart rqmp : qualityModelParts) { if (rqmp != null) { RenderableGeometry geom = (RenderableGeometry) rqmp; FloatBuffer fb = geom.getCoordBuffer(); fb.rewind(); int position = fb.position(); while (position < fb.capacity()) { float x = fb.get(); float y = fb.get(); float z = fb.get(); minX = Math.min(minX, x); minY = Math.min(minY, y); minZ = Math.min(minZ, z); maxX = Math.max(maxX, x); maxY = Math.max(maxY, y); maxZ = Math.max(maxZ, z); position = fb.position(); } } } double scaleX = 1d / (maxX - minX); double scaleY = 1d / (maxY - minY); double scaleZ = 1d / (maxZ - minZ); for (RenderableQualityModelPart rqmp : qualityModelParts) { if (rqmp != null) { RenderableGeometry geom = (RenderableGeometry) rqmp; FloatBuffer fb = geom.getCoordBuffer(); fb.rewind(); int i = 0; while ((i + 3) <= fb.capacity()) { float x = fb.get(i); x -= minX; x *= scaleX; fb.put(i, x); float y = fb.get(i + 1); y -= minY; y *= scaleY; fb.put(i + 1, y); float z = fb.get(i + 2); z -= minZ; z *= scaleZ; fb.put(i + 2, z); i += 3; } } } return rqm; }
From source file:com.opensymphony.xwork2.conversion.impl.NumberConverterTest.java
public void testStringToFloatConversionPL() throws Exception { // given/* w w w .j a va2 s . c om*/ NumberConverter converter = new NumberConverter(); Map<String, Object> context = new HashMap<>(); context.put(ActionContext.LOCALE, new Locale("pl", "PL")); // when has max fraction digits Object value = converter.convertValue(context, null, null, null, "0," + StringUtils.repeat('0', 44) + "1401298464324817", Float.class); // then does not lose fraction digits assertEquals(Float.MIN_VALUE, value); // when has max integer digits value = converter.convertValue(context, null, null, null, "34028234663852886" + StringUtils.repeat('0', 22) + ",0", Float.class); // then does not lose integer digits assertEquals(Float.MAX_VALUE, value); }
From source file:fr.immotronic.ubikit.pems.smartbuilding.impl.node.RelativeHumidityNodeImpl.java
@Override public float getRelativeHumidity() { if (isLocal()) { switch (getPemLocalID()) { case ENOCEAN: switch (eep) { case EEP_07_04_01: { EEP070401Data data = (EEP070401Data) getActualNodeValue(); if (data == null) { return Float.MIN_VALUE; }//from w w w.j av a2 s . c om return data.getRelativeHumidity(); } case EEP_07_10_11: { EEP0710xxData data = (EEP0710xxData) getActualNodeValue(); if (data == null) { return Float.MIN_VALUE; } return data.getRelativeHumidity(); } case EEP_07_09_04: { EEP070904Data data = (EEP070904Data) getActualNodeValue(); if (data == null) { return Float.MIN_VALUE; } return data.getRelativeHumidity(); } default: break; } break; } } return Float.MIN_VALUE; }
From source file:com.taobao.weex.devtools.json.ObjectMapperTest.java
@Test public void testObjectToPrimitive() throws JSONException { ArrayOfPrimitivesContainer container = new ArrayOfPrimitivesContainer(); ArrayList<Object> primitives = container.primitives; primitives.add(Long.MIN_VALUE); primitives.add(Long.MAX_VALUE); primitives.add(Integer.MIN_VALUE); primitives.add(Integer.MAX_VALUE); primitives.add(Float.MIN_VALUE); primitives.add(Float.MAX_VALUE); primitives.add(Double.MIN_VALUE); primitives.add(Double.MAX_VALUE); String json = mObjectMapper.convertValue(container, JSONObject.class).toString(); JSONObject obj = new JSONObject(json); JSONArray array = obj.getJSONArray("primitives"); ArrayList<Object> actual = new ArrayList<>(); for (int i = 0, N = array.length(); i < N; i++) { actual.add(array.get(i));/*from w w w.java 2 s . c o m*/ } assertEquals(primitives.toString(), actual.toString()); }
From source file:fr.immotronic.ubikit.pems.enocean.impl.item.data.EEP0710xxDataImpl.java
@Override public JSONObject toJSON() { JSONObject res = new JSONObject(); JSONObject o = null;//from w w w . j av a 2 s . c o m try { if (date == null) { res.put("noDataAvailable", true); return res; } long timestamp = date.getTime(); o = new JSONObject(); o.put(JSONValueField.value.name(), temperature); o.put(JSONValueField.uiValue.name(), df.format(temperature)); o.put(JSONValueField.unit.name(), " °C"); o.put(JSONValueField.timestamp.name(), timestamp); res.put("temperature", o); if (relativeHumidity != Float.MIN_VALUE) { o = new JSONObject(); o.put(JSONValueField.value.name(), relativeHumidity); o.put(JSONValueField.uiValue.name(), df.format(relativeHumidity)); o.put(JSONValueField.unit.name(), "%"); o.put(JSONValueField.timestamp.name(), timestamp); res.put("relativeHumidity", o); } if (fanSpeed != FanSpeed.UNKNOWN) { o = new JSONObject(); o.put(JSONValueField.value.name(), fanSpeed.name()); o.put(JSONValueField.uiValue.name(), fanSpeed.name()); o.put(JSONValueField.timestamp.name(), timestamp); res.put("fanSpeed", o); } if (setPoint != -1) { o = new JSONObject(); o.put(JSONValueField.value.name(), setPoint); o.put(JSONValueField.uiValue.name(), setPoint); o.put(JSONValueField.timestamp.name(), timestamp); res.put("setPoint", o); } if (lastOccupancyButtonPressDate != null) { o = new JSONObject(); o.put(JSONValueField.value.name(), lastOccupancyButtonPressDate.getTime()); o.put(JSONValueField.unit.name(), JSONValueSpecialUnit.duration.name()); res.put("lastOccupancyButtonPressDate", o); } if (dayNightState != DayNightState.UNKNOWN) { o = new JSONObject(); o.put(JSONValueField.value.name(), dayNightState.name()); o.put(JSONValueField.uiValue.name(), dayNightState.name()); o.put(JSONValueField.timestamp.name(), timestamp); res.put("dayNightState", o); } } catch (JSONException e) { Logger.error(LC.gi(), this, "toJSON(): An exception while building a JSON view of a EnoceanData SHOULD never happen. Check the code !", e); return null; } return res; }
From source file:fr.immotronic.ubikit.pems.smartbuilding.impl.node.HVACControllerNodeImpl.java
@Override public void setSetPointTemperature(float setPoint) throws IllegalArgumentException { if (setPoint < 0 || setPoint > 40) { throw new IllegalArgumentException("setPoint=" + setPoint + ". It MUST BE in the interval [0..40]."); }//from w ww. j a v a2 s . com switch (getPemLocalID()) { case ENOCEAN: switch (enoceanProfile) { case INTESIS_BOX_DK_RC_ENO_1i1iC_DEVICE: TemperatureAndSetPointEvent e = new TemperatureAndSetPointEvent(getActualNodeUID(), setPoint, Float.MIN_VALUE); lowerEventGate.postEvent(e); break; } break; default: break; } }
From source file:LineGraphDrawable.java
/** * Computes the scale factor to scale the given numeric data into the target * height./*from w w w.j a v a 2s . c om*/ * * @param data * the numeric data. * @param height * the target height of the graph. * @return the scale factor. */ public static float getDivisor(final Number[] data, final int height) { if (data == null) { throw new NullPointerException("Data array must not be null."); } if (height < 1) { throw new IndexOutOfBoundsException("Height must be greater or equal to 1"); } float max = Float.MIN_VALUE; float min = Float.MAX_VALUE; for (int index = 0; index < data.length; index++) { Number i = data[index]; if (i == null) { continue; } final float numValue = i.floatValue(); if (numValue < min) { min = numValue; } if (numValue > max) { max = numValue; } } if (max <= min) { return 1.0f; } if (height == 1) { return 0; } return (max - min) / (height - 1); }
From source file:fr.immotronic.ubikit.pems.enocean.impl.item.datahandler.EEP0710xxDataHandler.java
@Override public void processNewIncomingData(int transmitterID, EnoceanData data) { List<AbstractEvent> events = new ArrayList<AbstractEvent>(); byte[] dataBytes = data.getBytes(); // Checking if telegram is a teach-in telegram. If so, ignore it. if ((dataBytes[0] & 0x8) == 0x0) { return;//ww w. j a v a 2s .c o m } // Reading Fan Speed data, if any FanSpeed fanSpeed = FanSpeed.UNKNOWN; switch (EEPType) { case 0x1: case 0x2: case 0x4: case 0x7: case 0x8: case 0x9: int v = dataBytes[3] & 0xff; if (v >= 210) { fanSpeed = FanSpeed.AUTO; } else if (v >= 190 && v <= 209) { fanSpeed = FanSpeed.STAGE_0; } else if (v >= 165 && v <= 189) { fanSpeed = FanSpeed.STAGE_1; } else if (v >= 145 && v <= 164) { fanSpeed = FanSpeed.STAGE_2; } else if (v <= 144) { fanSpeed = FanSpeed.STAGE_3; } // Check if a change has occurred since last received data //if(fanSpeed != sensorData.getFanSpeed()) { // A change occurred, generate and send an event. events.add(new FanSpeedSelectionChangedEvent(itemUID, fanSpeed, data.getDate())); //} break; } // Reading Set Point data, if any int setPoint = -1; switch (EEPType) { case 0x1: case 0x2: case 0x3: case 0x4: case 0x5: case 0x6: case 0xA: setPoint = dataBytes[2] & 0xff; // Check if a change has occurred since last received data //if(setPoint != sensorData.getSetPoint()) { // A change occurred, generate and send an event. events.add(new SetPointChangedEvent(itemUID, setPoint, data.getDate())); //} break; case 0x10: case 0x11: case 0x12: setPoint = dataBytes[3] & 0xff; // Check if a change has occurred since last received data //if(setPoint != sensorData.getSetPoint()) { // A change occurred, generate and send an event. events.add(new SetPointChangedEvent(itemUID, setPoint, data.getDate())); //} break; } float temperature = Float.MIN_VALUE; switch (EEPType) { case 0x1: case 0x2: case 0x3: case 0x4: case 0x5: case 0x6: case 0x7: case 0x8: case 0x9: case 0xA: case 0xB: case 0xC: case 0xD: // According to Enocean Equipment Profile, temperature = 0..40C, DB1 = 255..0, linear temperature = (float) (255 - (int) (dataBytes[1] & 0xff)) * temperatureMultiplier_1; // Generate and send an temperature event. events.add(new TemperatureEvent(itemUID, temperature, data.getDate())); break; case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: // According to Enocean Equipment Profile, temperature = 0..40C, DB1 = 0..250, linear temperature = (float) (dataBytes[1] & 0xff) * temperatureMultiplier_2; // Generate and send an temperature event. events.add(new TemperatureEvent(itemUID, temperature, data.getDate())); break; } float relativeHumidity = Float.MIN_VALUE; switch (EEPType) { case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: // According to Enocean Equipment Profile, relativeHumidity = 0..100%, DB2 = 0..250, linear relativeHumidity = (float) (dataBytes[2] & 0xff) * relativeHumidityMultiplier; // Generate and send an relative humidity event. events.add(new RelativeHumidityEvent(itemUID, relativeHumidity, data.getDate())); break; } // Reading occupancy button data, if any Date lastOccupancyButtonPressDate = sensorData.getLastOccupancyButtonPressDate(); // Retain the old date, if occupancy button has not been pressed this time. switch (EEPType) { case 0x1: case 0x5: case 0x8: case 0xC: case 0x10: case 0x13: boolean occupancyButton = (dataBytes[0] & 0x1) == 0x0; // Worth true if the occupancy button is pressed if (occupancyButton) { lastOccupancyButtonPressDate = data.getDate(); events.add(new OccupancyButtonPressedEvent(itemUID, data.getDate())); } break; } // Reading the day/night slide switch, if any DayNightState dayNightState = sensorData.getDayNightState(); // Get the old state, if day/night button change, an event will be sent.; switch (EEPType) { case 0x2: case 0x6: case 0x9: case 0xD: case 0x11: case 0x14: boolean dayNightSlideSwitch = (dataBytes[0] & 0x1) == 0x0; // Worth true if the day/night slide switch is Night if (dayNightSlideSwitch) { //if(dayNightState != DayNightState.NIGHT) { events.add(new DayNightSlideSwitchChangedEvent(itemUID, dayNightState, data.getDate())); //} dayNightState = DayNightState.NIGHT; } else { //if(dayNightState != DayNightState.DAY) { events.add(new DayNightSlideSwitchChangedEvent(itemUID, dayNightState, data.getDate())); //} dayNightState = DayNightState.DAY; } break; } // Remembering received data sensorData = new EEP0710xxDataImpl(temperature, relativeHumidity, fanSpeed, setPoint, lastOccupancyButtonPressDate, dayNightState, data.getDate()); // And then, send all generated events. Sending MUST be done after remembering received data, otherwise if an event listener performs // a getLastKnownData() on event reception, it might obtain non up-to-date data. eventGate.postEvents(events); }
From source file:ome.server.itests.query.pojos.QueryTest.java
private void assertFloatsNotRounded(double dbl) { Correction correction = iQuery.findAll(Correction.class, null).get(0); Immersion immersion = iQuery.findAll(Immersion.class, null).get(0); Objective o = new Objective(); Instrument instrument = new Instrument(); o.setCorrection(correction);/*ww w . j a v a2 s. c om*/ o.setImmersion(immersion); o.setInstrument(instrument); // o.setLensNA(new Float(dbl)); o.setLensNA(dbl); Objective t1 = iUpdate.saveAndReturnObject(o); // Test value via jdbc String jdbcQuery = "SELECT lensNa FROM Objective WHERE id = :id"; Float lensNA = (Float) iQuery.projection(jdbcQuery, new Parameters().addId(t1.getId())).get(0)[0]; assertEquals(dbl, lensNA.floatValue(), 0.01); try { assertEquals(dbl, lensNA.floatValue(), Float.MIN_VALUE); } catch (AssertionFailedError e) { // This is what fails!! } // now test is with double which is our chosen solution Double lensNADoubled = (Double) iQuery.projection(jdbcQuery, new Parameters().addId(t1.getId())).get(0)[0]; assertEquals(dbl, lensNADoubled.doubleValue(), 0.01); assertEquals(dbl, lensNADoubled.doubleValue(), Float.MIN_VALUE); assertEquals(dbl, lensNADoubled.doubleValue(), Double.MIN_VALUE); // Test value return by iUpdate // Now changing these to doubleValue() post #1150 fix. assertEquals(dbl, t1.getLensNA().doubleValue(), 0.001); assertEquals(dbl, t1.getLensNA().doubleValue(), Float.MIN_VALUE); assertEquals(dbl, t1.getLensNA().doubleValue()); // Test via query Objective t2 = iQuery.find(Objective.class, o.getId()); assertEquals(dbl, t2.getLensNA().doubleValue()); }