List of usage examples for java.lang Float toString
public static String toString(float f)
From source file:org.openhab.binding.max.internal.message.CMessage.java
private void parseHeatingThermostatData(byte[] bytes) { try {//from www . j av a 2s .com int plusDataStart = 18; int programDataStart = 11; tempComfort = new BigDecimal((bytes[plusDataStart] & 0xFF) / 2D); tempEco = new BigDecimal((bytes[plusDataStart + 1] & 0xFF) / 2D); tempSetpointMax = new BigDecimal((bytes[plusDataStart + 2] & 0xFF) / 2D); tempSetpointMin = new BigDecimal((bytes[plusDataStart + 3] & 0xFF) / 2D); properties.put(PROPERTY_THERMO_COMFORT_TEMP, tempComfort.setScale(1, RoundingMode.HALF_DOWN)); properties.put(PROPERTY_THERMO_ECO_TEMP, tempEco.setScale(1, RoundingMode.HALF_DOWN)); properties.put(PROPERTY_THERMO_MAX_TEMP_SETPOINT, tempSetpointMax.setScale(1, RoundingMode.HALF_DOWN)); properties.put(PROPERTY_THERMO_MIN_TEMP_SETPOINT, tempSetpointMin.setScale(1, RoundingMode.HALF_DOWN)); if (bytes.length < 211) { // Device is a WallMountedThermostat programDataStart = 4; logger.trace("WallThermostat byte {}: {}", bytes.length - 3, Float.toString(bytes[bytes.length - 3] & 0xFF)); logger.trace("WallThermostat byte {}: {}", bytes.length - 2, Float.toString(bytes[bytes.length - 2] & 0xFF)); logger.trace("WallThermostat byte {}: {}", bytes.length - 1, Float.toString(bytes[bytes.length - 1] & 0xFF)); } else { // Device is a HeatingThermostat(+) tempOffset = new BigDecimal((bytes[plusDataStart + 4] & 0xFF) / 2D - 3.5); tempOpenWindow = new BigDecimal((bytes[plusDataStart + 5] & 0xFF) / 2D); durationOpenWindow = new BigDecimal((bytes[plusDataStart + 6] & 0xFF) * 5); boostDuration = new BigDecimal(bytes[plusDataStart + 7] & 0xFF >> 5); boostValve = new BigDecimal((bytes[plusDataStart + 7] & 0x1F) * 5); decalcification = new BigDecimal(bytes[plusDataStart + 8]); valveMaximum = new BigDecimal((bytes[plusDataStart + 9] & 0xFF) * 100 / 255); valveOffset = new BigDecimal((bytes[plusDataStart + 10] & 0xFF) * 100 / 255); properties.put(PROPERTY_THERMO_OFFSET_TEMP, tempOffset.setScale(1, RoundingMode.HALF_DOWN)); properties.put(PROPERTY_THERMO_WINDOW_OPEN_TEMP, tempOpenWindow.setScale(1, RoundingMode.HALF_DOWN)); properties.put(PROPERTY_THERMO_WINDOW_OPEN_DURATION, durationOpenWindow.setScale(0, RoundingMode.HALF_DOWN)); properties.put(PROPERTY_THERMO_BOOST_DURATION, boostDuration.setScale(0, RoundingMode.HALF_DOWN)); properties.put(PROPERTY_THERMO_BOOST_VALVEPOS, boostValve.setScale(0, RoundingMode.HALF_DOWN)); properties.put(PROPERTY_THERMO_DECALCIFICATION, decalcification.setScale(0, RoundingMode.HALF_DOWN)); properties.put(PROPERTY_THERMO_VALVE_MAX, valveMaximum.setScale(0, RoundingMode.HALF_DOWN)); properties.put(PROPERTY_THERMO_VALVE_OFFSET, valveOffset.setScale(0, RoundingMode.HALF_DOWN)); } programData = ""; int ln = 13 * 6; // first day = Sat String startTime = "00:00h"; for (int charIdx = plusDataStart + programDataStart; charIdx < (plusDataStart + programDataStart + 26 * 7); charIdx++) { if (ln % 13 == 0) { programData += "\r\n Day " + Integer.toString((ln / 13) % 7) + ": "; startTime = "00:00h"; } int progTime = (bytes[charIdx + 1] & 0xFF) * 5 + (bytes[charIdx] & 0x01) * 1280; int progMinutes = progTime % 60; int progHours = (progTime - progMinutes) / 60; String endTime = Integer.toString(progHours) + ":" + String.format("%02d", progMinutes) + "h"; programData += startTime + "-" + endTime + " " + Double.toString(bytes[charIdx] / 4) + "C "; startTime = endTime; charIdx++; ln++; } } catch (Exception e) { logger.debug("Exception occurred during heater data: {}", e.getMessage(), e); } return; }
From source file:com.variable.demo.api.fragment.MotionFragment.java
@Override public void onMagnetometerUpdate(MotionSensor sensor, MotionReading reading) { Message m = mHandler.obtainMessage(MessageConstants.MESSAGE_MAGNETOMETER_READING); Bundle b = m.getData();/*from www. j a v a 2 s . c o m*/ b.putFloat(MessageConstants.X_VALUE_KEY, (reading.getX() + 6) * DECIMAL_PRECISION); b.putFloat(MessageConstants.Y_VALUE_KEY, (reading.getY() + 6) * DECIMAL_PRECISION); b.putFloat(MessageConstants.Z_VALUE_KEY, (reading.getZ() + 6) * DECIMAL_PRECISION); //For this demo we are streaming all time stamp from the node device. b.putLong(MessageConstants.TIME_STAMP, reading.getTimeStamp().getTime()); b.putInt(MessageConstants.TIME_SOURCE, reading.getTimeStampSource()); final Context thiscontext = this.getActivity(); final String serialnumOne = sensor.getSerialNumber(); final String serialnum = serialnumOne.replaceAll("[^\\u0000-\\uFFFF]", ""); final String scanX = Float.toString((reading.getX() + 16) * DECIMAL_PRECISION); final String scanY = Float.toString((reading.getY() + 16) * DECIMAL_PRECISION); final String scanZ = Float.toString((reading.getZ() + 16) * DECIMAL_PRECISION); String json = "magnetometer;" + serialnum + ";" + scanX + "," + scanY + "," + scanZ; // POST to variable dashboard Ion.getDefault(thiscontext).getConscryptMiddleware().enable(false); Ion.with(thiscontext).load( "https://datadipity.com/clickslide/fleetplusdata.json?PHPSESSID=gae519f8k5humje0jqb195nob6&update&postparam[payload]=" + json) .setLogging("MyLogs", Log.DEBUG).asString().withResponse() .setCallback(new FutureCallback<Response<String>>() { @Override public void onCompleted(Exception e, Response<String> result) { if (e == null) { Log.i(TAG, "ION SENT MESSAGE WITH RESULT CODE: " + result.toString()); } else { Log.i(TAG, "ION SENT MESSAGE WITH EXCEPTION"); e.printStackTrace(); } } }); m.sendToTarget(); }
From source file:com.thanu.schoolbustracker.RouteActivity.java
@Override public void onMapLongClick(LatLng point) { if (name == null || name.equalsIgnoreCase("Admin")) { locationCount++;/*w w w.j ava2s. c o m*/ // Drawing marker on the map drawMarker(point); /** Opening the editor object to write data to sharedPreferences */ SharedPreferences.Editor editor = sharedPreferences.edit(); // Storing the latitude for the i-th location editor.putString("lat" + Integer.toString((locationCount - 1)), Double.toString(point.latitude)); // Storing the longitude for the i-th location editor.putString("lng" + Integer.toString((locationCount - 1)), Double.toString(point.longitude)); // Storing the count of locations or marker count editor.putInt("locationCount", locationCount); /** Storing the zoom level to the shared preferences */ editor.putString("zoom", Float.toString(myMap.getCameraPosition().zoom)); /** Saving the values stored in the shared preferences */ editor.commit(); // Setting latitude in ContentValues lat = point.latitude; latitude = (Double.valueOf(lat)).toString(); // Setting longitude in ContentValues lon = point.longitude; longitude = (Double.valueOf(lon)).toString(); // Setting zoom in ContentValues zoomLevel = myMap.getCameraPosition().zoom; zoom = (Float.valueOf(zoomLevel)).toString(); // Creating an instance of LocationInsertTask new LocationInsertTask().execute(); Toast.makeText(getBaseContext(), "Marker is added to the Map", Toast.LENGTH_SHORT).show(); markerClicked = false; } }
From source file:blue.soundObject.tracker.Track.java
public NoteList generateNotes() throws NoteParseException { NoteList retVal = new NoteList(); String instrId = getInstrumentId(); try {//from www .ja va2 s . co m Float.parseFloat(instrId); } catch (NumberFormatException nfe) { instrId = "\"" + instrId + "\""; } String noteTemplate = TextUtilities.replaceAll(getNoteTemplate(), "<INSTR_ID>", instrId); noteTemplate = TextUtilities.replaceAll(noteTemplate, "<INSTR_NAME>", getInstrumentId()); for (int i = 0; i < trackerNotes.size(); i++) { TrackerNote trNote = (TrackerNote) trackerNotes.get(i); if (trNote.isActive() && !trNote.isOff()) { String noteStr = noteTemplate; int dur = 1; for (int j = i + 1; j < trackerNotes.size(); j++) { TrackerNote temp = (TrackerNote) trackerNotes.get(j); if (temp.isActive() || temp.isOff()) { break; } dur++; } String durStr = trNote.isTied() ? "-" + dur : Integer.toString(dur); noteStr = TextUtilities.replaceAll(noteStr, "<START>", Integer.toString(i)); noteStr = TextUtilities.replaceAll(noteStr, "<DUR>", durStr); Object[] colNameArg = new Object[1]; for (int j = 1; j < getNumColumns(); j++) { Column col = getColumn(j); colNameArg[0] = col.getName(); String colNameStr = COL_NAME.format(colNameArg); String newValue = trNote.getValue(j); if (col.getType() == Column.TYPE_BLUE_PCH && col.isOutputFrequency()) { String[] parts = newValue.split("\\."); int octave = Integer.parseInt(parts[0]); int scaleDegree = Integer.parseInt(parts[1]); float freq = col.getScale().getFrequency(octave, scaleDegree); newValue = Float.toString(freq); } noteStr = TextUtilities.replaceAll(noteStr, colNameStr, newValue); } Note note = Note.createNote(noteStr); retVal.addNote(note); } } return retVal; }
From source file:com.gvccracing.android.tttimer.Tabs.RaceInfoTab.java
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { try {/*from w w w .j a va 2s . c o m*/ Log.i(LOG_TAG(), "onLoadFinished start: id=" + Integer.toString(loader.getId())); switch (loader.getId()) { case RACE_INFO_LOADER: cursor.moveToFirst(); if (cursor.getCount() > 0) { Long raceDateMS = cursor.getLong(cursor.getColumnIndex(Race.RaceDate)); String courseName = cursor.getString(cursor.getColumnIndex(RaceLocation.CourseName)); long raceTypeID = cursor.getLong(cursor.getColumnIndex(Race.RaceType)); String raceTypeName = RaceType.DescriptionFromRaceTypeID(raceTypeID); String startIntervalText = Long .toString(cursor.getLong(cursor.getColumnIndex(Race.StartInterval))); long numRaceLaps = cursor.getLong(cursor.getColumnIndex(Race.NumLaps)); distance = Float.toString( cursor.getFloat(cursor.getColumnIndex(RaceLocation.Distance)) * (float) numRaceLaps); if (distance == null) { distance = ""; } if (raceTypeID == 1) { raceLaps.setText(Long.toString(numRaceLaps)); llRaceLaps.setVisibility(View.VISIBLE); } else { llRaceLaps.setVisibility(View.GONE); } Date raceDateTemp = new Date(raceDateMS); SimpleDateFormat formatter = new SimpleDateFormat("M/d/yy"); raceDate.setText(formatter.format(raceDateTemp).toString()); raceCourseName.setText(courseName); raceType.setText(raceTypeName); raceStartInterval.setText(startIntervalText); SetDistance(); } break; case APP_SETTINGS_LOADER_RACEINFO: getActivity().getSupportLoaderManager().restartLoader(COURSE_RECORD_LOADER, null, this); Integer distanceUnitID = Integer.parseInt(AppSettings.Instance().ReadValue(getActivity(), AppSettings.AppSetting_DistanceUnits_Name, "0")); distanceUnit = "mi"; switch (distanceUnitID) { case 0: distanceUnit = "mi"; break; case 1: distanceUnit = "km"; break; default: distanceUnit = "mi"; break; } getActivity().getSupportLoaderManager().restartLoader(RACE_INFO_LOADER, null, this); break; case COURSE_RECORD_LOADER: if (cursor != null && cursor.getCount() > 0) { cursor.moveToFirst(); long elapsedTime = cursor.getLong(cursor.getColumnIndex(RaceResults.ElapsedTime)); if (courseRecord != null) { courseRecord.setText(TimeFormatter.Format(elapsedTime, true, true, true, true, true, false, false, false)); } } break; } Log.i(LOG_TAG(), "onLoadFinished complete: id=" + Integer.toString(loader.getId())); } catch (Exception ex) { Log.e(LOG_TAG(), "onLoadFinished error", ex); } }
From source file:com.verisign.storm.metrics.GraphiteMetricsConsumerTest.java
@DataProvider(name = "generateMapDataPoints") public Object[][] generateMapDataPoints() { int numDataPoints = 5; int numDataPointValues = 5; Object[][] testData = new Object[numDataPoints][1]; for (int i = 0; i < numDataPoints; i++) { Collection<DataPoint> dpList = new ArrayList<DataPoint>(); HashMap<String, Object> dpMap = new HashMap<String, Object>(); for (int j = 0; j < numDataPointValues; j++) { dpMap.put(RandomStringUtils.randomAlphanumeric(10), rng.nextInt()); dpMap.put(RandomStringUtils.randomAlphanumeric(10), Integer.toString(rng.nextInt())); dpMap.put(RandomStringUtils.randomAlphanumeric(10), rng.nextLong()); dpMap.put(RandomStringUtils.randomAlphanumeric(10), Long.toString(rng.nextLong())); dpMap.put(RandomStringUtils.randomAlphanumeric(10), rng.nextFloat()); dpMap.put(RandomStringUtils.randomAlphanumeric(10), Float.toString(rng.nextFloat())); dpMap.put(RandomStringUtils.randomAlphanumeric(10), rng.nextDouble()); dpMap.put(RandomStringUtils.randomAlphanumeric(10), Double.toString(rng.nextDouble())); dpMap.put(RandomStringUtils.randomAlphanumeric(10), RandomStringUtils.randomAlphanumeric(10)); dpMap.put(RandomStringUtils.randomAlphanumeric(10), null); dpMap.put(RandomStringUtils.randomAlphanumeric(10), Integer.toString(rng.nextInt())); }/*from ww w .ja va2s . co m*/ DataPoint dp = new DataPoint(RandomStringUtils.randomAlphanumeric(10), dpMap); dpList.add(dp); testData[i][0] = dpList; } return testData; }
From source file:havidarou.com.appgestosfoto.MainActivity.java
@Override public boolean onTouchEvent(MotionEvent event) { // Get the event in order to switch between the options int action = MotionEventCompat.getActionMasked(event); a1.getLocationInWindow(p1);//from ww w . ja v a 2s . c o m a2.getLocationInWindow(p2); a3.getLocationInWindow(p3); b1.getLocationInWindow(p4); b2.getLocationInWindow(p5); b3.getLocationInWindow(p6); c1.getLocationInWindow(p7); c2.getLocationInWindow(p8); c3.getLocationInWindow(p9); switch (action) { // If the movement has just begun case (MotionEvent.ACTION_DOWN): helper.setText("Do a recognized pattern"); // Get the initial point initialX = event.getX(event.getPointerId(0)); initialY = event.getY(event.getPointerId(0)); Log.d("X:", Float.toString(initialX)); Log.d("Y:", Float.toString(initialY)); break; // If the user is moving across the screen case (MotionEvent.ACTION_MOVE): // Get the current point currentX = event.getX(event.getPointerId(0)); currentY = event.getY(event.getPointerId(0)); // Depending on the current position and where are we moving we add to the current movement if ((currentX > p1[0] - 60 && currentX < p1[0] + 70) && (currentY > p1[1] - 60) && (currentY < p1[1] + 70) && (movement.get(movement.size() - 1) != 1)) { Log.d("Movement:", Float.toString(1)); movement.add(1); } else if ((currentX > p2[0] - 60 && currentX < p2[0] + 70) && (currentY > p2[1] - 60) && (currentY < p2[1] + 70) && (movement.get(movement.size() - 1) != 2)) { Log.d("Movement:", Float.toString(2)); movement.add(2); } else if ((currentX > p3[0] - 60 && currentX < p3[0] + 70) && (currentY > p3[1] - 60) && (currentY < p3[1] + 70) && (movement.get(movement.size() - 1) != 3)) { Log.d("Movement:", Float.toString(3)); movement.add(3); } else if ((currentX > p4[0] - 60 && currentX < p4[0] + 70) && (currentY > p4[1] - 60) && (currentY < p4[1] + 70) && (movement.get(movement.size() - 1) != 4)) { Log.d("Movement:", Float.toString(4)); movement.add(4); } else if ((currentX > p5[0] - 60 && currentX < p5[0] + 70) && (currentY > p5[1] - 60) && (currentY < p5[1] + 70) && (movement.get(movement.size() - 1) != 5)) { Log.d("Movement:", Float.toString(5)); movement.add(5); } else if ((currentX > p6[0] - 60 && currentX < p6[0] + 70) && (currentY > p6[1] - 60) && (currentY < p6[1] + 70) && (movement.get(movement.size() - 1) != 6)) { Log.d("Movement:", Float.toString(6)); movement.add(6); } else if ((currentX > p7[0] - 60 && currentX < p7[0] + 70) && (currentY > p7[1] - 60) && (currentY < p7[1] + 70) && (movement.get(movement.size() - 1) != 7)) { Log.d("Movement:", Float.toString(7)); movement.add(7); } else if ((currentX > p8[0] - 50 && currentX < p8[0] + 70) && (currentY > p8[1] - 60) && (currentY < p8[1] + 70) && (movement.get(movement.size() - 1) != 8)) { Log.d("Movement:", Float.toString(8)); movement.add(8); } else if ((currentX > p9[0] - 60 && currentX < p9[0] + 70) && (currentY > p9[1] - 60) && (currentY < p9[1] + 70) && (movement.get(movement.size() - 1) != 9)) { Log.d("Movement:", Float.toString(9)); movement.add(9); } break; // If the user stops touching the screen then we check if the pattern matches with any of the recognized ones case (MotionEvent.ACTION_UP): if (movement.equals(zMovement) || movement.equals(lMovement) || movement.equals(mMovement) || movement.equals(nMovement) || movement.equals(vMovement)) { rightPattern = true; helper.setText("Recognized pattern"); view.setVisibility(View.VISIBLE); a1.setVisibility(View.INVISIBLE); a2.setVisibility(View.INVISIBLE); a3.setVisibility(View.INVISIBLE); b1.setVisibility(View.INVISIBLE); b2.setVisibility(View.INVISIBLE); b3.setVisibility(View.INVISIBLE); c1.setVisibility(View.INVISIBLE); c2.setVisibility(View.INVISIBLE); c3.setVisibility(View.INVISIBLE); try { camera.setPreviewDisplay(view.getHolder()); // Associate the holder with the preview } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } camera.setDisplayOrientation(90); camera.startPreview(); // A recognized pattern has been done, now we start the timer startTimer(view); } else { helper.setText("Unrecognized pattern"); } movement.clear(); movement.add(0); break; } return true; }
From source file:CircleOfSquares.java
void ExecuteNextInstruction() { int a, b, result, i; float fa, fb, fresult; Float f;/* w w w . j a va 2 s . co m*/ int operand0, operand1; int nextOpCode = methodAreaMemorySection.getAtAddress(pcRegister); switch (nextOpCode) { case OpCode.BIPUSH: operand0 = methodAreaMemorySection.getAtAddress(pcRegister + 1); stackMemorySection.setAtAddress(optopRegister, operand0); stackMemorySection.setLogicalValueAtAddress(optopRegister, StringTable.operand); optopRegister += 4; pcRegister += 2; break; case OpCode.FCONST_0: stackMemorySection.setAtAddress(optopRegister, Float.floatToIntBits((float) 0)); stackMemorySection.setLogicalValueAtAddress(optopRegister, "0"); optopRegister += 4; ++pcRegister; break; case OpCode.FCONST_2: stackMemorySection.setAtAddress(optopRegister, Float.floatToIntBits((float) 2)); stackMemorySection.setLogicalValueAtAddress(optopRegister, "2"); optopRegister += 4; ++pcRegister; break; case OpCode.FLOAD_0: a = stackMemorySection.getAtAddress(varsRegister); stackMemorySection.setAtAddress(optopRegister, a); fa = Float.intBitsToFloat(a); stackMemorySection.setLogicalValueAtAddress(optopRegister, Float.toString(fa)); optopRegister += 4; ++pcRegister; break; case OpCode.FMUL: optopRegister -= 4; a = stackMemorySection.getAtAddress(optopRegister); fa = Float.intBitsToFloat(a); stackMemorySection.setLogicalValueAtAddress(optopRegister, ""); optopRegister -= 4; b = stackMemorySection.getAtAddress(optopRegister); fb = Float.intBitsToFloat(b); fresult = fa * fb; result = Float.floatToIntBits(fresult); stackMemorySection.setAtAddress(optopRegister, result); stackMemorySection.setLogicalValueAtAddress(optopRegister, Float.toString(fresult)); optopRegister += 4; ++pcRegister; break; case OpCode.FSTORE_0: optopRegister -= 4; a = stackMemorySection.getAtAddress(optopRegister); stackMemorySection.setLogicalValueAtAddress(optopRegister, ""); stackMemorySection.setAtAddress(varsRegister, a); fa = Float.intBitsToFloat(a); stackMemorySection.setLogicalValueAtAddress(varsRegister, Float.toString(fa)); ++pcRegister; break; case OpCode.FSUB: optopRegister -= 4; a = stackMemorySection.getAtAddress(optopRegister); fa = Float.intBitsToFloat(a); stackMemorySection.setLogicalValueAtAddress(optopRegister, ""); optopRegister -= 4; b = stackMemorySection.getAtAddress(optopRegister); fb = Float.intBitsToFloat(b); fresult = fb - fa; result = Float.floatToIntBits(fresult); stackMemorySection.setAtAddress(optopRegister, result); stackMemorySection.setLogicalValueAtAddress(optopRegister, Float.toString(fresult)); optopRegister += 4; ++pcRegister; break; case OpCode.GOTO: operand1 = methodAreaMemorySection.getAtAddress(pcRegister + 1); operand0 = methodAreaMemorySection.getAtAddress(pcRegister + 2); int offset = (operand1 << 8) | (operand0 & 0xff); pcRegister += offset; break; case OpCode.IADD: optopRegister -= 4; a = stackMemorySection.getAtAddress(optopRegister); stackMemorySection.setLogicalValueAtAddress(optopRegister, ""); optopRegister -= 4; b = stackMemorySection.getAtAddress(optopRegister); result = a + b; stackMemorySection.setAtAddress(optopRegister, result); optopRegister += 4; ++pcRegister; break; case OpCode.ICONST_M1: stackMemorySection.setAtAddress(optopRegister, -1); stackMemorySection.setLogicalValueAtAddress(optopRegister, StringTable.operand); optopRegister += 4; ++pcRegister; break; case OpCode.ICONST_0: stackMemorySection.setAtAddress(optopRegister, 0); stackMemorySection.setLogicalValueAtAddress(optopRegister, StringTable.operand); optopRegister += 4; ++pcRegister; break; case OpCode.ICONST_1: stackMemorySection.setAtAddress(optopRegister, 1); stackMemorySection.setLogicalValueAtAddress(optopRegister, StringTable.operand); optopRegister += 4; ++pcRegister; break; case OpCode.ICONST_2: stackMemorySection.setAtAddress(optopRegister, 2); stackMemorySection.setLogicalValueAtAddress(optopRegister, StringTable.operand); optopRegister += 4; ++pcRegister; break; case OpCode.IINC: operand0 = methodAreaMemorySection.getAtAddress(pcRegister + 1); operand1 = methodAreaMemorySection.getAtAddress(pcRegister + 2); a = stackMemorySection.getAtAddress(varsRegister + (operand0 * 4)); a += operand1; stackMemorySection.setAtAddress(varsRegister + (operand0 * 4), a); pcRegister += 3; break; case OpCode.ILOAD_0: a = stackMemorySection.getAtAddress(varsRegister); stackMemorySection.setAtAddress(optopRegister, a); stackMemorySection.setLogicalValueAtAddress(optopRegister, StringTable.operand); optopRegister += 4; ++pcRegister; break; case OpCode.ILOAD_1: a = stackMemorySection.getAtAddress(varsRegister + 4); stackMemorySection.setAtAddress(optopRegister, a); stackMemorySection.setLogicalValueAtAddress(optopRegister, StringTable.operand); optopRegister += 4; ++pcRegister; break; case OpCode.IMUL: optopRegister -= 4; a = stackMemorySection.getAtAddress(optopRegister); stackMemorySection.setLogicalValueAtAddress(optopRegister, ""); optopRegister -= 4; b = stackMemorySection.getAtAddress(optopRegister); result = a * b; stackMemorySection.setAtAddress(optopRegister, result); optopRegister += 4; ++pcRegister; break; case OpCode.INT2BYTE: a = stackMemorySection.getAtAddress(optopRegister - 4); a = (byte) a; stackMemorySection.setAtAddress(optopRegister - 4, a); stackMemorySection.setLogicalValueAtAddress(optopRegister - 4, StringTable.operand); ++pcRegister; break; case OpCode.ISTORE_0: optopRegister -= 4; a = stackMemorySection.getAtAddress(optopRegister); stackMemorySection.setLogicalValueAtAddress(optopRegister, ""); stackMemorySection.setAtAddress(varsRegister, a); ++pcRegister; break; case OpCode.ISTORE_1: optopRegister -= 4; a = stackMemorySection.getAtAddress(optopRegister); stackMemorySection.setLogicalValueAtAddress(optopRegister + 4, ""); stackMemorySection.setAtAddress(varsRegister + 4, a); ++pcRegister; break; } }
From source file:org.jts.eclipse.conversion.cjsidl.ConversionUtil.java
/** * Used to fill a gap where a minimum value isn't specified in a range. * @param val - the current value, if there is one. * @param inputType - the input data type that the minimum should fit within * /*from w ww. j a va2s. c o m*/ * @return - the original value if it exists, or the minimum value allowed within * the inputType specified. */ public static String getCountMin(String val, String inputType) { String result = val; if (result == null || result.isEmpty()) { if (inputType.equals("byte") || inputType.equals("int8")) { result = Byte.toString(Byte.MIN_VALUE); } else if (inputType.equals("short integer") || inputType.equals("int16")) { result = Short.toString(Short.MIN_VALUE); } else if (inputType.equals("integer") || inputType.equals("int32")) { result = Integer.toString(Integer.MIN_VALUE); } else if (inputType.equals("long integer") || inputType.equals("int64")) { result = Long.toString(Long.MIN_VALUE); } else if (inputType.equals("unsigned byte") || inputType.equals("uint8")) { result = "0"; } else if (inputType.equals("unsigned short integer") || inputType.equals("uint16")) { result = "0"; } else if (inputType.equals("unsigned integer") || inputType.equals("uint32")) { result = "0"; } else if (inputType.equals("unsigned long integer") || inputType.equals("uint64")) { result = "0"; } else if (inputType.equals("float") || inputType.equals("float")) { result = Float.toString(Float.MIN_VALUE); } else if (inputType.equals("long float") || inputType.equals("double")) { result = Double.toString(Double.MIN_VALUE); } } return result; }
From source file:alaindc.crowdroid.SensorsIntentService.java
public final void onSensorChanged(SensorEvent event) { Log.d("SENSORS_INTENTSERVICE", event.toString()); // Hack Reduce updates if (random.nextInt(10) < 9) return;/* w w w . j ava 2 s. co m*/ SharedPreferences sharedPref = getApplicationContext().getSharedPreferences(Constants.PREF_FILE, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPref.edit(); editor.putString(Constants.PREF_SENSOR_ + event.sensor.getType(), Float.toString(event.values[0])); editor.commit(); // Update view Intent senseintent = new Intent(Constants.INTENT_UPDATE_SENSORS); senseintent.putExtra(Constants.INTENT_RECEIVED_DATA_EXTRA_DATA, "Sensor " + Constants.getNameOfSensor(event.sensor.getType()) + " value: " + Float.toString(event.values[0])); LocalBroadcastManager.getInstance(this).sendBroadcast(senseintent); }