|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.extex.typesetter.Badness
public final class Badness
This class provides some static methods to deal with badness values.
| Field Summary | |
|---|---|
static int |
EJECT_PENALTY
The constant EJECT_PENALTY contains the penalty which forces a line break. |
static int |
INF_BAD
The constant INF_BAD contains the value for infinite badness. |
static int |
INF_PENALTY
The constant INF_BAD contains the value for infinite penalty. |
| Method Summary | |
|---|---|
static int |
badness(long total,
long sum)
Compute the badness. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int EJECT_PENALTY
public static final int INF_BAD
public static final int INF_PENALTY
| Method Detail |
|---|
public static int badness(long total,
long sum)
108. The next subroutine is used to compute the badness of
glue, when a total t is supposed to be made from amounts that
sum to s. According to The
The actual method used to compute the badness is easier to read
from the program than to describe in words. It produces an
integer value that is a reasonably close approximation to
100(t/s)3, and all implementations of
It is not difficult to prove that
badness(t+1,s) ≥ badness(t,s) ≥ badness(t,s+1).
The badness function defined here is capable of computing at most 1095 distinct values, but that is plenty.
define inf_bad=10000 {infinitely bad value}
function badness(t,s:scaled): halfword; {compute badness, given t ≥ 0}
var r: integer; {approximation to αt/s, where α3 ≈ 100⋅218}
begin if t=0 then badness ← 0
else if s ≤ 0 then badness ← inf_bad
else begin if t ≤ 7230584 then r ← (t * 297) div s {2973 = 99.94 × 218}
else if s ≥ 1663497 then r ← t div (s div 297)
else r ← t;
if r>1290 then badness ← inf_bad {12903<231<12913}
else badness ← (r*r*r+'400000) div '1000000;
end ; {that was r3/218, rounded to the nearest integer}
end ;
total - total given total >= 0sum - sum
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||