F2Dot14.java
1.08 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.agl.text.DecimalFormat
*/
package com.adobe.fontengine.math;
import com.adobe.agl.text.DecimalFormat;
public final class F2Dot14 {
public static final int ZERO = 0;
public static final int ONE = 16384;
public static final int ONE_SIXTEENTH = 1024;
private static final DecimalFormat df = new DecimalFormat("0.###");
private static int clamp(long x) {
if (x > 32767) {
return 32767;
}
if (x < -32768) {
return -32768;
}
return (int)x;
}
public static int multiply(int v1, int v2) {
return F2Dot14.clamp(((long)v1 * (long)v2 >> 13) + 1 >> 1);
}
public static int square(int v) {
return F2Dot14.multiply(v, v);
}
public static int fromDouble(double v) {
return (int)(v * 16384.0);
}
public static double toDouble(int v) {
return (double)v / 16384.0;
}
public static String toString(int v) {
return df.format(F2Dot14.toDouble(v));
}
}