|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.ranides.assira.math.MathUtils
public final class MathUtils
| Method Summary | |
|---|---|
static double |
clip(double value,
double min,
double max)
Przycina podaną wartość do podanego zakresu. |
static float |
clip(float value,
float min,
float max)
Przycina podaną wartość do podanego zakresu. |
static int |
clip(int value,
int min,
int max)
Przycina podaną wartość do podanego zakresu. |
static boolean |
inRange(byte value,
byte min,
byte max)
Sprawdza, czy podana wartość mieści się w określonym zakresie (domkniętym). |
static boolean |
inRange(int value,
int min,
int max)
Sprawdza, czy podana wartość mieści się w określonym zakresie (domkniętym). |
static boolean |
inRange(long value,
long min,
long max)
Sprawdza, czy podana wartość mieści się w określonym zakresie (domkniętym). |
static int |
roundClip(double value,
int min,
int max)
Przycina podaną wartość do podanego zakresu i zaokrągla do liczby całkowitej. |
static long |
roundClip(double value,
long min,
long max)
Przycina podaną wartość do podanego zakresu i zaokrągla do liczby całkowitej. |
static int |
signum(long diff)
Alternate to signum for use in compare. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static boolean inRange(int value,
int min,
int max)
value - min - max -
public static boolean inRange(byte value,
byte min,
byte max)
value - min - max -
public static boolean inRange(long value,
long min,
long max)
value - min - max -
public static int clip(int value,
int min,
int max)
value < min, to zwraca min, jeśli
value > max, to zwraca max, jeśli wartość mieści się w
podanym zakresie, to jest zwracana bez zmian.
value - min - max -
public static double clip(double value,
double min,
double max)
value < min, to zwraca min, jeśli
value > max, to zwraca max, jeśli wartość mieści się w
podanym zakresie, to jest zwracana bez zmian.
value - min - max -
public static float clip(float value,
float min,
float max)
value < min, to zwraca min, jeśli
value > max, to zwraca max, jeśli wartość mieści się w
podanym zakresie, to jest zwracana bez zmian.
value - min - max -
public static int roundClip(double value,
int min,
int max)
value < min, to zwraca min, jeśli
value > max, to zwraca max, jeśli wartość mieści się w
podanym zakresie, to jest zwracana bez zmian.
value - min - max -
public static long roundClip(double value,
long min,
long max)
value < min, to zwraca min, jeśli
value > max, to zwraca max, jeśli wartość mieści się w
podanym zakresie, to jest zwracana bez zmian.
value - min - max -
public static int signum(long diff)
In Pentium assembler you could implement this algorthm with following code:
# diff = edx:eax # result = eax mov ebx,eax shl eax,1 or eax,ebx slr eax,1 or eax,edxwhich would take 5 cycles, 2 more that lohi. However, JET did even better, with code essentially this using a clever trick to implement piotr.
lea ecx,0(eax,eax) ; shifts lo left by doubling, keeps copy of lo or eax,ecx shr eax,1 or eax,edxThis is 4 cycles, still one more than lohi. Why was Piotr so much faster on JET? Peter has no pipeline-confounding jumps. Further, the lo then high operands actually come from the ram-based stack. Piotr nicely separates the accesses giving plenty of for pre-emptive fetch of hi. lohi insists on having them both upfront, so it has to wait for memory access. Piotr does not have to wait. Modern CPUS hurry up and wait for RAM most of the time.
diff - number to be collapsed to an int preserving sign and
zeroness. usually represents the difference of two long.
diff, some int < 0, 0 or some int > 0.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||