com.badlogic.gdx.utils.NumberUtils Java Examples
The following examples show how to use
com.badlogic.gdx.utils.NumberUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Version.java From gdx-texture-packer-gui with Apache License 2.0 | 5 votes |
@Override public int hashCode() { int result = (major != +0.0f ? NumberUtils.floatToIntBits(major) : 0); result = 31 * result + (minor != +0.0f ? NumberUtils.floatToIntBits(minor) : 0); result = 31 * result + (revision != +0.0f ? NumberUtils.floatToIntBits(revision) : 0); return result; }
Example #2
Source File: Tools.java From gdx-proto with Apache License 2.0 | 5 votes |
public static float readFloatFromBytes(byte[] bytes, int offset) { int i = 0; int value = bytes[0 + offset] & 0xFF; value |= bytes[1 + offset]<<(8) & 0xFFFF; value |= bytes[2 + offset]<<(16) & 0xFFFFFF; value |= bytes[3 + offset]<<(24) & 0xFFFFFFFF; return NumberUtils.intBitsToFloat(value); }
Example #3
Source File: Tools.java From gdx-proto with Apache License 2.0 | 5 votes |
public static int writeFloatToBytes(float f, byte[] bytes, int offset) { int value = NumberUtils.floatToIntBits(f); bytes[0 + offset] = (byte) (value & 0xFF); bytes[1 + offset] = (byte) (value>>8 & 0xFF); bytes[2 + offset] = (byte) (value>>16 & 0xFF); bytes[3 + offset] = (byte) (value>>24 & 0xFF); // return next idx return offset + 4; }
Example #4
Source File: TerrainTextureAttribute.java From Mundus with Apache License 2.0 | 4 votes |
@Override public int hashCode() { final int prime = 7; final long v = NumberUtils.doubleToLongBits(terrainTexture.hashCode()); return prime * super.hashCode() + (int) (v ^ (v >>> 32)); }
Example #5
Source File: PaletteReducer.java From gdx-texture-packer-gui with Apache License 2.0 | 2 votes |
/** * Gets a pseudo-random float between -0.3f and 0.7f, determined by the lower 23 bits and upper 2 bits of seed. * The average value this returns will be less than 0f, despite its upper bound being further from 0 than its * lower bound, because values between 0.2f and 0.7f are a third as likely to appear as values less than 0.125f, * and even for values less than 0.2f, the range between -0.05f and 0.2f is a third as likely as the range from * -0.3f to 0.05f. This introduced bias can be useful for adding some order to otherwise-random dithering. * @param seed any int, but only the least-significant 23 bits will be used * @return a float between -0.3f and 0.7f, weighted toward the lower end of the range */ public static float randomXi(int seed) { return NumberUtils.intBitsToFloat((seed & 0x7FFFFF & ((seed >>> 11 & 0x600000)|0x1FFFFF)) | 0x3f800000) - 1.3f; }