List of usage examples for java.lang Float intBitsToFloat
@HotSpotIntrinsicCandidate public static native float intBitsToFloat(int bits);
From source file:uk.co.modularaudio.mads.base.frequencyfilter.mu.FrequencyFilterIOQueueBridge.java
@Override public void receiveQueuedEventsToInstance(final FrequencyFilterMadInstance instance, final ThreadSpecificTemporaryEventStorage tses, final long periodTimestamp, final IOQueueEvent queueEntry) { switch (queueEntry.command) { case COMMAND_FILTER_MODE: { // float/*from w ww. j a va2 s . c om*/ final long value = queueEntry.value; final int truncVal = (int) value; instance.setDesiredFilterMode(FrequencyFilterMode.values()[truncVal]); break; } case COMMAND_FREQUENCY: { // float final long value = queueEntry.value; final int truncVal = (int) value; final float floatVal = Float.intBitsToFloat(truncVal); instance.setDesiredFrequency(floatVal); break; } case COMMAND_BANDWIDTH: { // float final long value = queueEntry.value; final int truncVal = (int) value; final float floatVal = Float.intBitsToFloat(truncVal); instance.setDesiredBandwidth(floatVal); break; } case COMMAND_DBTOGGLE: { final long value = queueEntry.value; final int truncVal = (int) value; final boolean bVal = (truncVal == 0 ? false : true); instance.setDesired24dB(bVal); break; } default: { final String msg = "Unknown command passed on incoming queue: " + queueEntry.command; log.error(msg); } } }
From source file:AtomicFloat.java
private static final float f(final int i) { return Float.intBitsToFloat(i); }
From source file:Main.java
/** * Returns the floating-point value adjacent to <code>f</code> in * the direction of positive infinity. This method is * semantically equivalent to <code>nextAfter(f, * Double.POSITIVE_INFINITY)</code>; however, a <code>nextUp</code> * implementation may run faster than its equivalent * <code>nextAfter</code> call. * * <p>Special Cases:/*from w w w . ja va 2s . c o m*/ * <ul> * <li> If the argument is NaN, the result is NaN. * * <li> If the argument is positive infinity, the result is * positive infinity. * * <li> If the argument is zero, the result is * <code>Float.MIN_VALUE</code> * * </ul> * * @param f starting floating-point value * @return The adjacent floating-point value closer to positive * infinity. * @author Joseph D. Darcy */ public static float nextUp(float f) { if (isNaN(f) || f == FloatConsts.POSITIVE_INFINITY) return f; else { f += 0.0f; return Float.intBitsToFloat(Float.floatToRawIntBits(f) + ((f >= 0.0f) ? +1 : -1)); } }
From source file:Main.java
/** * Returns the floating-point value adjacent to <code>f</code> in * the direction of negative infinity. This method is * semantically equivalent to <code>nextAfter(f, * Float.NEGATIVE_INFINITY)</code>; however, a * <code>nextDown</code> implementation may run faster than its * equivalent <code>nextAfter</code> call. * * <p>Special Cases:/*w ww . j a v a2 s . co m*/ * <ul> * <li> If the argument is NaN, the result is NaN. * * <li> If the argument is negative infinity, the result is * negative infinity. * * <li> If the argument is zero, the result is * <code>-Float.MIN_VALUE</code> * * </ul> * * @param f starting floating-point value * @return The adjacent floating-point value closer to negative * infinity. * @author Joseph D. Darcy */ public static double nextDown(float f) { if (isNaN(f) || f == Float.NEGATIVE_INFINITY) return f; else { if (f == 0.0f) return -Float.MIN_VALUE; else return Float.intBitsToFloat(Float.floatToRawIntBits(f) + ((f > 0.0f) ? -1 : +1)); } }
From source file:org.apache.cassandra.stress.generate.FasterRandom.java
public float nextFloat() { return Float.intBitsToFloat((int) nextLong()); }
From source file:uk.co.modularaudio.mads.base.stereo_compressor.mu.StereoCompressorIOQueueBridge.java
@Override public void receiveQueuedEventsToInstance(final StereoCompressorMadInstance instance, final ThreadSpecificTemporaryEventStorage tses, final long periodTimestamp, final IOQueueEvent queueEntry) { switch (queueEntry.command) { case COMMAND_IN_THRESHOLD: { final float valueAsFloat = Float.intBitsToFloat((int) queueEntry.value); instance.desiredThresholdDb = valueAsFloat; // log.debug("Set desired threshold dB to " + instance.desiredThresholdDb ); break;/*from ww w. j a va2 s.com*/ } case COMMAND_IN_THRESHOLD_TYPE: { final int valueAsInt = (int) queueEntry.value; instance.desiredThresholdType = ThresholdTypeEnum.values()[valueAsInt]; // log.debug("Set thresholdtype to " + instance.desiredThresholdType ); break; } case COMMAND_IN_ATTACK_MILLIS: { final int valueAsInt = (int) queueEntry.value; final float valAsFloat = Float.intBitsToFloat(valueAsInt); instance.desiredAttack = valAsFloat; instance.attackSamples = AudioTimingUtils.getNumSamplesForMillisAtSampleRate(instance.sampleRate, valAsFloat); // log.debug("Set attack millis to " + valAsFloat + " which is " + instance.attackSamples + " samples"); break; } case COMMAND_IN_RELEASE_MILLIS: { final int valueAsInt = (int) queueEntry.value; final float valAsFloat = Float.intBitsToFloat(valueAsInt); instance.desiredRelease = valAsFloat; instance.releaseSamples = AudioTimingUtils.getNumSamplesForMillisAtSampleRate(instance.sampleRate, valAsFloat); // log.debug("Set release millis to " + valAsFloat + " which is " + instance.releaseSamples + " samples"); break; } case COMMAND_IN_RATIO: { final int valueAsInt = (int) queueEntry.value; float valAsFloat = Float.intBitsToFloat(valueAsInt); valAsFloat = (valAsFloat == 0.0f ? 1.0f : valAsFloat); instance.desiredCompRatio = 1.0f / valAsFloat; // log.debug("Set ratio to " + valAsFloat + " which is " + instance.desiredCompRatio + " as a multiplier"); break; } case COMMAND_IN_MAKEUP_GAIN: { final int valueAsInt = (int) queueEntry.value; float valAsFloat = Float.intBitsToFloat(valueAsInt); valAsFloat = (valAsFloat == 0.0f ? 1.0f : valAsFloat); instance.desiredMakeupGain = (float) AudioMath.dbToLevel(valAsFloat); // log.debug("Set makeup gain to " + valAsFloat + " which is " + instance.desiredMakeupGain + " as a multiplier"); break; } case COMMAND_IN_ACTIVE: { instance.active = queueEntry.value == 1; break; } case COMMAND_IN_LOOKAHEAD: { final boolean bValue = queueEntry.value == 1; instance.desiredLookahead = bValue; break; } default: { if (log.isErrorEnabled()) { log.error("Unknown command to instance: " + queueEntry.command); } break; } } }
From source file:uk.co.modularaudio.mads.base.scopen.mu.ScopeNIOQueueBridge.java
@Override public void receiveQueuedEventsToInstance(final I instance, final ThreadSpecificTemporaryEventStorage tses, final long periodTimestamp, final IOQueueEvent queueEntry) { switch (queueEntry.command) { case COMMAND_IN_ACTIVE: { final boolean active = (queueEntry.value == 1); instance.setActive(active);/*w w w . j a va 2 s. c om*/ break; } case COMMAND_IN_CAPTURE_MILLIS: { final int intBits = (int) queueEntry.value; final float captureMillis = Float.intBitsToFloat(intBits); instance.setCaptureMillis(captureMillis); break; } case COMMAND_IN_TRIGGER: { final TriggerChoice trigger = TriggerChoice.values()[(int) queueEntry.value]; instance.setTriggerChoice(trigger); break; } case COMMAND_IN_REPETITION: { final RepetitionChoice repetition = RepetitionChoice.values()[(int) queueEntry.value]; instance.setRepetitionChoice(repetition); break; } case COMMAND_IN_RECAPTURE: { instance.doRecapture(tses, periodTimestamp); break; } default: { final String msg = "Unknown command passed on incoming queue: " + queueEntry.command; log.error(msg); } } }
From source file:uk.co.modularaudio.mads.base.imixern.mu.MixerNIOQueueBridge.java
@Override public void receiveQueuedEventsToInstance(final I instance, final ThreadSpecificTemporaryEventStorage tses, final long currentTimestamp, final IOQueueEvent queueEntry) { switch (queueEntry.command) { case COMMAND_IN_ACTIVE: { final boolean isActive = (queueEntry.value == 1); instance.setActive(isActive);/*from ww w .jav a 2 s . co m*/ break; } case COMMAND_IN_LANE_AMP: { // float final long value = queueEntry.value; final int lower32Bits = (int) ((value) & 0xFFFFFFFF); final int upper32Bits = (int) ((value >> 32) & 0xFFFFFFFF); final float ampValue = Float.intBitsToFloat(upper32Bits); // log.debug("Received lane amp on lane " + lower32Bits + " change " + lower32Bits + ", " + ampValue ); instance.setLaneAmp(lower32Bits, ampValue); break; } case COMMAND_IN_LANE_PAN: { // float final long value = queueEntry.value; final int lower32Bits = (int) ((value) & 0xFFFFFFFF); final int upper32Bits = (int) ((value >> 32) & 0xFFFFFFFF); final float panValue = Float.intBitsToFloat(upper32Bits); // log.debug("Received lane amp change " + lower32Bits + ", " + ampValue ); instance.setLanePan(lower32Bits, panValue); break; } case COMMAND_IN_LANE_MUTE: { final long value = queueEntry.value; final int laneNumber = (int) ((value) & 0xFFFFFFFF); final int upper32Bits = (int) ((value >> 32) & 0xFFFFFFFF); final boolean muteValue = (upper32Bits != 0); instance.setLaneMute(tses, currentTimestamp, laneNumber, muteValue); break; } case COMMAND_IN_LANE_SOLO: { final long value = queueEntry.value; final int laneNumber = (int) ((value) & 0xFFFFFFFF); final int upper32Bits = (int) ((value >> 32) & 0xFFFFFFFF); final boolean soloValue = (upper32Bits != 0); instance.setLaneSolo(tses, currentTimestamp, laneNumber, soloValue); break; } default: { final String msg = "Unknown command passed on incoming queue: " + queueEntry.command; log.error(msg); } } }
From source file:com.dal.vv.type.AbstractValue.java
@Override public float asFloat() { return Float.intBitsToFloat(asInt()); }
From source file:org.apache.jcs.utils.struct.LRUMapPerformanceTest.java
/** * *///from w ww.j a va2 s. c o m public void doWork() { long start = 0; long end = 0; long time = 0; float tPer = 0; long putTotalJCS = 0; long getTotalJCS = 0; long putTotalHashtable = 0; long getTotalHashtable = 0; String name = "LRUMap"; String cache2Name = ""; try { Map cache = new LRUMap(tries); for (int j = 0; j < loops; j++) { name = "JCS "; start = System.currentTimeMillis(); for (int i = 0; i < tries; i++) { cache.put("key:" + i, "data" + i); } end = System.currentTimeMillis(); time = end - start; putTotalJCS += time; tPer = Float.intBitsToFloat((int) time) / Float.intBitsToFloat(tries); System.out.println(name + " put time for " + tries + " = " + time + "; millis per = " + tPer); start = System.currentTimeMillis(); for (int i = 0; i < tries; i++) { cache.get("key:" + i); } end = System.currentTimeMillis(); time = end - start; getTotalJCS += time; tPer = Float.intBitsToFloat((int) time) / Float.intBitsToFloat(tries); System.out.println(name + " get time for " + tries + " = " + time + "; millis per = " + tPer); /////////////////////////////////////////////////////////////// cache2Name = "LRUMapJCS (commons)"; //or LRUMapJCS Map cache2 = new org.apache.commons.collections.map.LRUMap(tries); //cache2Name = "Hashtable"; //Hashtable cache2 = new Hashtable(); start = System.currentTimeMillis(); for (int i = 0; i < tries; i++) { cache2.put("key:" + i, "data" + i); } end = System.currentTimeMillis(); time = end - start; putTotalHashtable += time; tPer = Float.intBitsToFloat((int) time) / Float.intBitsToFloat(tries); System.out.println(cache2Name + " put time for " + tries + " = " + time + "; millis per = " + tPer); start = System.currentTimeMillis(); for (int i = 0; i < tries; i++) { cache2.get("key:" + i); } end = System.currentTimeMillis(); time = end - start; getTotalHashtable += time; tPer = Float.intBitsToFloat((int) time) / Float.intBitsToFloat(tries); System.out.println(cache2Name + " get time for " + tries + " = " + time + "; millis per = " + tPer); System.out.println("\n"); } } catch (Exception e) { e.printStackTrace(System.out); System.out.println(e); } long putAvJCS = putTotalJCS / loops; long getAvJCS = getTotalJCS / loops; long putAvHashtable = putTotalHashtable / loops; long getAvHashtable = getTotalHashtable / loops; System.out.println("Finished " + loops + " loops of " + tries + " gets and puts"); System.out.println("\n"); System.out.println("Put average for LRUMap = " + putAvJCS); System.out.println("Put average for " + cache2Name + " = " + putAvHashtable); ratioPut = Float.intBitsToFloat((int) putAvJCS) / Float.intBitsToFloat((int) putAvHashtable); System.out.println( name + " puts took " + ratioPut + " times the " + cache2Name + ", the goal is <" + targetPut + "x"); System.out.println("\n"); System.out.println("Get average for LRUMap = " + getAvJCS); System.out.println("Get average for " + cache2Name + " = " + getAvHashtable); ratioGet = Float.intBitsToFloat((int) getAvJCS) / Float.intBitsToFloat((int) getAvHashtable); System.out.println( name + " gets took " + ratioGet + " times the " + cache2Name + ", the goal is <" + targetGet + "x"); }