Example usage for java.lang Float floatToIntBits

List of usage examples for java.lang Float floatToIntBits

Introduction

In this page you can find the example usage for java.lang Float floatToIntBits.

Prototype

@HotSpotIntrinsicCandidate
public static int floatToIntBits(float value) 

Source Link

Document

Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "single format" bit layout.

Usage

From source file:uk.co.modularaudio.mads.base.djeq.ui.DJEQMadUiInstance.java

public void setFaderAmp(final float faderAmp) {
    final long lValue = Float.floatToIntBits(faderAmp);
    sendTemporalValueToInstance(DJEQIOQueueBridge.COMMAND_IN_FADER_AMP, lValue);
}

From source file:at.alladin.rmbt.statisticServer.StatisticParameters.java

@Override
public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (obj == null)
        return false;
    if (getClass() != obj.getClass())
        return false;
    StatisticParameters other = (StatisticParameters) obj;
    if (lang == null) {
        if (other.lang != null)
            return false;
    } else if (!lang.equals(other.lang))
        return false;
    if (maxDevices != other.maxDevices)
        return false;
    if (duration != other.duration)
        return false;
    if (networkTypeGroup == null) {
        if (other.networkTypeGroup != null)
            return false;
    } else if (!networkTypeGroup.equals(other.networkTypeGroup))
        return false;
    if (Float.floatToIntBits(quantile) != Float.floatToIntBits(other.quantile))
        return false;
    if (accuracy != other.accuracy) {
        return false;
    }//from w w  w.ja  v  a2  s. c  o  m
    if (country != null && other.country != null && !country.equals(other.country)) {
        return false;
    }
    if (type == null) {
        if (other.type != null)
            return false;
    } else if (!type.equals(other.type))
        return false;
    return true;
}

From source file:uk.co.modularaudio.mads.base.imixern.ui.MixerNMadUiInstance.java

public void sendLanePan(final int laneNumber, final float panValue) {
    final long floatIntBits = Float.floatToIntBits(panValue);
    final long joinedParts = (floatIntBits << 32) | laneNumber;
    sendTemporalValueToInstance(MixerNIOQueueBridge.COMMAND_IN_LANE_PAN, joinedParts);
}

From source file:uk.co.modularaudio.mads.base.stereo_compressor.ui.StereoCompressorMadUiInstance.java

public void sendThreshold(final float desiredThreshold) {
    final long value = Float.floatToIntBits(desiredThreshold);
    sendTemporalValueToInstance(StereoCompressorIOQueueBridge.COMMAND_IN_THRESHOLD, value);
    thresholdValueReceiver.receiveNewDbValue(desiredThreshold);
}

From source file:Armadillo.Analytics.Base.Precision.java

/**
 * Returns true if both arguments are equal or within the range of allowed
 * error (inclusive).//from  w  w w.j av a2  s.  c  om
 * Two float numbers are considered equal if there are {@code (maxUlps - 1)}
 * (or fewer) floating point numbers between them, i.e. two adjacent floating
 * point numbers are considered equal.
 * Adapted from <a
 * href="http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm">
 * Bruce Dawson</a>
 *
 * @param x first value
 * @param y second value
 * @param maxUlps {@code (maxUlps - 1)} is the number of floating point
 * values between {@code x} and {@code y}.
 * @return {@code true} if there are fewer than {@code maxUlps} floating
 * point values between {@code x} and {@code y}.
 * @since 2.2
 */
public static boolean equals(float x, float y, int maxUlps) {
    int xInt = Float.floatToIntBits(x);
    int yInt = Float.floatToIntBits(y);

    // Make lexicographically ordered as a two's-complement integer.
    if (xInt < 0) {
        xInt = SGN_MASK_FLOAT - xInt;
    }
    if (yInt < 0) {
        yInt = SGN_MASK_FLOAT - yInt;
    }

    final boolean isEqual = FastMath.abs(xInt - yInt) <= maxUlps;

    return isEqual && !Float.isNaN(x) && !Float.isNaN(y);
}

From source file:cross.io.misc.Base64Util.java

/**
 * Returns a byte array representing the float values in the IEEE 754
 * floating-point "single format" bit layout.
 *
 * @param floatList a list of float values
 * @param bigEndian//ww  w  .  ja va 2s  .  c  o  m
 * @return a byte array representing the float values in the IEEE 754
 *         floating-point "single format" bit layout.
 */
public static byte[] floatListToByteArray(final List<Float> floatList, final boolean bigEndian) {
    final int floatListSize = floatList.size();
    final byte[] raw = new byte[floatListSize * 4];
    int jjj = 0;
    if (bigEndian) {
        for (int iii = 0; iii < floatListSize; iii++) {
            final Float aFloat = floatList.get(iii);
            final int ieee754 = Float.floatToIntBits(aFloat.floatValue());
            raw[jjj] = (byte) ((ieee754 >> 24) & 0xff);
            raw[jjj + 1] = (byte) ((ieee754 >> 16) & 0xff);
            raw[jjj + 2] = (byte) ((ieee754 >> 8) & 0xff);
            raw[jjj + 3] = (byte) ((ieee754) & 0xff);
            jjj += 4;
        }
    } else {
        for (int iii = 0; iii < floatListSize; iii++) {
            final Float aFloat = floatList.get(iii);
            final int ieee754 = Float.floatToIntBits(aFloat.floatValue());
            raw[jjj] = (byte) ((ieee754) & 0xff);
            raw[jjj + 1] = (byte) ((ieee754 >> 8) & 0xff);
            raw[jjj + 2] = (byte) ((ieee754 >> 16) & 0xff);
            raw[jjj + 3] = (byte) ((ieee754 >> 24) & 0xff);
            jjj += 4;
        }
    }
    return raw;
}

From source file:uk.co.modularaudio.mads.base.stereo_compressor.ui.StereoCompressorMadUiInstance.java

public void sendRatio(final float desiredRatio) {
    final long value = Float.floatToIntBits(desiredRatio);
    sendTemporalValueToInstance(StereoCompressorIOQueueBridge.COMMAND_IN_RATIO, value);
}

From source file:HashCode.java

/**
 * Generate a hash code for a float value.
 * // www  . j a  v  a2  s . c  o m
 * @param value
 *          Float value to generate hash code from.
 * @return Hash code.
 */
public static int generate(final float value) {
    return Float.floatToIntBits(value);
}

From source file:org.diorite.TeleportData.java

@Override
public int hashCode() {
    int result;//from w  ww.j av a2 s  . c  o  m
    long temp;
    temp = Double.doubleToLongBits(this.x);
    result = (int) (temp ^ (temp >>> 32));
    temp = Double.doubleToLongBits(this.y);
    result = (31 * result) + (int) (temp ^ (temp >>> 32));
    temp = Double.doubleToLongBits(this.z);
    result = (31 * result) + (int) (temp ^ (temp >>> 32));
    result = (31 * result) + ((this.yaw != +0.0f) ? Float.floatToIntBits(this.yaw) : 0);
    result = (31 * result) + ((this.pitch != +0.0f) ? Float.floatToIntBits(this.pitch) : 0);
    result = (31 * result) + (this.isXRelatvie ? 1 : 0);
    result = (31 * result) + (this.isYRelatvie ? 1 : 0);
    result = (31 * result) + (this.isZRelatvie ? 1 : 0);
    result = (31 * result) + (this.isYawRelatvie ? 1 : 0);
    result = (31 * result) + (this.isPitchRelatvie ? 1 : 0);
    return result;
}

From source file:uk.co.modularaudio.mads.base.stereo_compressor.ui.StereoCompressorMadUiInstance.java

public void sendAttack(final float desiredAttack) {
    final long value = Float.floatToIntBits(desiredAttack);
    sendTemporalValueToInstance(StereoCompressorIOQueueBridge.COMMAND_IN_ATTACK_MILLIS, value);
}