blob: 35e2aaaf431f29c290d8dc40081fd14a158ee8b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package javax.media.opengl.util;
public class FixedPoint {
public static final int toFixed(int value) {
if (value < -32768) value = -32768;
if (value > 32767) value = 32767;
return value * 65536;
}
public static final int toFixed(float value) {
if (value < -32768) value = -32768;
if (value > 32767) value = 32767;
return (int)(value * 65536.0f);
}
public static final float toFloat(int value) {
return (float)value/65536.0f;
}
public static final int mult(int x1, int x2) {
return (int) ( ((long)x1*(long)x2)/65536 );
}
public static final int div(int x1, int x2) {
return (int) ( (((long)x1)<<16)/x2 );
}
}
|