Example usage for java.lang Double doubleToRawLongBits

List of usage examples for java.lang Double doubleToRawLongBits

Introduction

In this page you can find the example usage for java.lang Double doubleToRawLongBits.

Prototype

@HotSpotIntrinsicCandidate
public static native long doubleToRawLongBits(double value);

Source Link

Document

Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "double format" bit layout, preserving Not-a-Number (NaN) values.

Usage

From source file:com.pgmacdesign.rsrtoolbox.TEST.java

Editor putDouble(final Editor edit, final String key, final double value) {
    return edit.putLong(key, Double.doubleToRawLongBits(value));
}

From source file:TypeConversionHelper.java

/**
 * Convert an instance of our value class into a byte[].
 *
 * @param value Object to be converted//  w  w w . j  a v a 2  s . c  om
 *
 * @return converted byte array
 */
public static byte[] getByteArrayFromDoubleArray(Object value) {
    if (value == null) {
        return null;
    }

    double[] a = (double[]) value;
    int n = a.length;
    byte[] buf = new byte[n * 8];
    int i = 0;
    int j = 0;

    for (; i < n;) {
        long x = Double.doubleToRawLongBits(a[i++]);
        buf[j++] = (byte) ((x >>> 56) & 0xFF);
        buf[j++] = (byte) ((x >>> 48) & 0xFF);
        buf[j++] = (byte) ((x >>> 40) & 0xFF);
        buf[j++] = (byte) ((x >>> 32) & 0xFF);
        buf[j++] = (byte) ((x >>> 24) & 0xFF);
        buf[j++] = (byte) ((x >>> 16) & 0xFF);
        buf[j++] = (byte) ((x >>> 8) & 0xFF);
        buf[j++] = (byte) (x & 0xFF);
    }

    return buf;
}

From source file:com.nextgis.woody.fragment.MapFragment.java

@Override
public void onPause() {
    pauseGps();//from  w  ww  .  j a va2s.co  m

    final SharedPreferences.Editor edit = PreferenceManager.getDefaultSharedPreferences(getActivity()).edit();
    if (null != mMap && !mShowSelectLocation) {
        edit.putFloat(SettingsConstants.KEY_PREF_ZOOM_LEVEL, mMap.getZoomLevel());
        GeoPoint point = mMap.getMapCenter();
        edit.putLong(SettingsConstants.KEY_PREF_SCROLL_X, Double.doubleToRawLongBits(point.getX()));
        edit.putLong(SettingsConstants.KEY_PREF_SCROLL_Y, Double.doubleToRawLongBits(point.getY()));

        mMap.removeListener(this);
    }
    edit.commit();

    super.onPause();
}

From source file:com.intuit.wasabi.experimentobjects.ExperimentValidator.java

public void validateExperimentBuckets(List<Bucket> buckets) {

    if ((buckets == null) || (buckets.isEmpty())) {
        throw new IllegalArgumentException("No experiment buckets specified");
    }//from w  w  w. j  a  va2  s  .com

    Double totalAllocation = 0.0;
    Integer numControl = 0;
    Integer nOpen = 0;
    for (Bucket bucket : buckets) {

        Double val = bucket.getAllocationPercent();

        totalAllocation += val;

        if (bucket.getState() == Bucket.State.OPEN || bucket.getState() == null) {
            nOpen++;
        }
        if (bucket.isControl()) {
            numControl++;
        }
    }

    if ((nOpen > 0 && Math.abs(totalAllocation - 1.0) > 1e-12)
            || (nOpen == 0 && Double.doubleToRawLongBits(totalAllocation) != 0)) {
        throw new IllegalArgumentException(
                "Total allocation must be 1.0 (or 0.0 if all buckets are closed/empty");
    }
    if (numControl > 1) {
        throw new IllegalArgumentException("Only one bucket may be specified as a control bucket");
    }
}

From source file:com.jfolson.hive.serde.RTypedBytesOutput.java

/**
 * Writes a double as a typed bytes sequence.
 *
 * @param d//  www .  j  a  v a  2 s .c om
 *          the double to be written
 * @throws IOException
 */
public void writeRawDouble(double d) throws IOException {
    out.writeLong(Double.doubleToRawLongBits(d));
}

From source file:com.dal.vv.type.AbstractValue.java

@Override
public Value load(double data) {
    return load(Double.doubleToRawLongBits(data));
}

From source file:dynamite.zafroshops.app.MainActivity.java

SharedPreferences.Editor putDouble(final SharedPreferences.Editor edit, final String key, final double value) {
    return edit.putLong(key, Double.doubleToRawLongBits(value));
}

From source file:com.nextgis.ngm_clink_monitoring.fragments.MapFragment.java

@Override
public void onPause() {
    if (null != mGpsEventSource) {
        mGpsEventSource.removeListener(this);
    }/*from   w w  w  .jav  a  2s . com*/

    if (null != mCurrentLocationOverlay) {
        mCurrentLocationOverlay.stopShowingCurrentLocation();
    }

    final SharedPreferences.Editor edit = PreferenceManager.getDefaultSharedPreferences(getActivity()).edit();

    if (null != mMapView) {
        mMapView.removeListener(this);

        edit.putFloat(FoclSettingsConstantsUI.KEY_PREF_ZOOM_LEVEL, mMapView.getZoomLevel());
        GeoPoint point = mMapView.getMapCenter();
        edit.putLong(FoclSettingsConstantsUI.KEY_PREF_SCROLL_X, Double.doubleToRawLongBits(point.getX()));
        edit.putLong(FoclSettingsConstantsUI.KEY_PREF_SCROLL_Y, Double.doubleToRawLongBits(point.getY()));
    }

    edit.commit();

    super.onPause();
}

From source file:com.aurel.track.fieldType.runtime.matchers.run.AccountingTimeMatcherRT.java

/**
 * Safe compare double value with 0//from  ww  w .  j a  v  a2s.com
 * 
 * @param value
 * @return true if this value is really zero (bitwise compare)
 */
public static boolean isZero(Double value) {
    return (Double.doubleToRawLongBits(value) - Double.doubleToRawLongBits(zeroDouble) == 0);
}

From source file:com.secupwn.aimsicd.utils.Helpers.java

public static void getOpenCellData(InjectionAppCompatActivity injectionActivity, Cell cell, char type,
        final AimsicdService service) {
    if (Helpers.isNetAvailable(injectionActivity)) {
        if (!"NA".equals(CellTracker.OCID_API_KEY)) {
            double earthRadius = 6371.01; // [Km]
            int radius = 2; // Use a 2 Km radius with center at GPS location.

            if (Double.doubleToRawLongBits(cell.getLat()) != 0
                    && Double.doubleToRawLongBits(cell.getLon()) != 0) {
                //New GeoLocation object to find bounding Coordinates
                GeoLocation currentLoc = GeoLocation.fromDegrees(cell.getLat(), cell.getLon());

                //Calculate the Bounding Box Coordinates using an N Km "radius" //0=min, 1=max
                GeoLocation[] boundingCoords = currentLoc.boundingCoordinates(radius, earthRadius);
                String boundParameter;

                //Request OpenCellID data for Bounding Coordinates (0 = min, 1 = max)
                boundParameter = String.valueOf(boundingCoords[0].getLatitudeInDegrees()) + ","
                        + String.valueOf(boundingCoords[0].getLongitudeInDegrees()) + ","
                        + String.valueOf(boundingCoords[1].getLatitudeInDegrees()) + ","
                        + String.valueOf(boundingCoords[1].getLongitudeInDegrees());

                log.info("OCID BBOX is set to: " + boundParameter + "  with radius " + radius + " Km.");

                StringBuilder sb = new StringBuilder();
                sb.append("http://www.opencellid.org/cell/getInArea?key=").append(CellTracker.OCID_API_KEY)
                        .append("&BBOX=").append(boundParameter);

                log.info("OCID MCC is set to: " + cell.getMobileCountryCode());
                if (cell.getMobileCountryCode() != Integer.MAX_VALUE) {
                    sb.append("&mcc=").append(cell.getMobileCountryCode());
                }//from  www.j a  v a 2  s.com
                log.info("OCID MNC is set to: " + cell.getMobileNetworkCode());
                if (cell.getMobileNetworkCode() != Integer.MAX_VALUE) {
                    sb.append("&mnc=").append(cell.getMobileNetworkCode());
                }

                sb.append("&format=csv");
                new RequestTask(injectionActivity, type, new RequestTask.AsyncTaskCompleteListener() {
                    @Override
                    public void onAsyncTaskSucceeded() {
                        log.verbose(
                                "RequestTask's OCID download was successful. Callback rechecking connected cell against database");
                        service.getCellTracker().compareLacAndOpenDb();
                    }

                    @Override
                    public void onAsyncTaskFailed(String result) {
                    }
                }).execute(sb.toString());
            }
        } else {
            Fragment myFragment = injectionActivity.getSupportFragmentManager()
                    .findFragmentByTag(String.valueOf(DrawerMenu.ID.MAIN.ALL_CURRENT_CELL_DETAILS));
            if (myFragment instanceof MapFragment) {
                ((MapFragment) myFragment).setRefreshActionButtonState(false);
            }
            Helpers.sendMsg(injectionActivity,
                    injectionActivity.getString(R.string.no_opencellid_key_detected));
        }
    } else {
        Fragment myFragment = injectionActivity.getSupportFragmentManager()
                .findFragmentByTag(String.valueOf(DrawerMenu.ID.MAIN.ALL_CURRENT_CELL_DETAILS));
        if (myFragment instanceof MapFragment) {
            ((MapFragment) myFragment).setRefreshActionButtonState(false);
        }

        final AlertDialog.Builder builder = new AlertDialog.Builder(injectionActivity);
        builder.setTitle(R.string.no_network_connection_title)
                .setMessage(R.string.no_network_connection_message);
        builder.create().show();
    }
}