org.extex.core.scaled
Class ScaledNumber

java.lang.Object
  extended by org.extex.core.scaled.ScaledNumber

public class ScaledNumber
extends java.lang.Object

This class provides a fixed point number.

Version:
$Revision: 4404 $
Author:
Gerd Neugebauer

Field Summary
static long ONE
          The constant ONE contains the internal representation for 1pt.
 
Constructor Summary
ScaledNumber()
          Creates a new object.
ScaledNumber(long value)
          Creates a new object.
 
Method Summary
 void add(long scaled)
          Add a number to the current one.
 void add(ScaledNumber scaled)
          Add a number to the current one.
 void divide(long scaled)
          Divide the scaled value by a number.
 boolean eq(ScaledNumber d)
          Compares the current instance with another ScaledNumber for equality.
 boolean ge(ScaledNumber d)
          Compares the current instance with another ScaledNumber.
 long getValue()
          Getter for the value.
 boolean le(ScaledNumber d)
          Compares the current instance with another ScaledNumber.
 boolean lt(ScaledNumber d)
          Compares the current instance with another ScaledNumber.
 void multiply(long scaled)
          Multiply the current value by a scaled number.
 void multiply(long nom, long denom)
          Multiply the value by an integer fraction.
 void negate()
          Negate the current value.
 void set(long scaled)
          Set the value to a new one
 void set(ScaledNumber scaled)
          Setter for the value
 void subtract(ScaledNumber scaled)
          Subtract a number from the current one.
 java.lang.String toString()
          Determine the printable representation of the object.
static void toString(java.lang.StringBuffer sb, long value)
          Determine the printable representation of the object and append it to the given StringBuffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ONE

public static final long ONE
The constant ONE contains the internal representation for 1pt.

See Also:
"TeX – The Program [101]", Constant Field Values
Constructor Detail

ScaledNumber

public ScaledNumber()
Creates a new object.


ScaledNumber

public ScaledNumber(long value)
Creates a new object.

Parameters:
value - the initial value
Method Detail

toString

public static void toString(java.lang.StringBuffer sb,
                            long value)
Determine the printable representation of the object and append it to the given StringBuffer.

Parameters:
sb - the output string buffer
value - the internal value in multiples of ONE

add

public void add(long scaled)
Add a number to the current one.

Parameters:
scaled - the number to add

add

public void add(ScaledNumber scaled)
Add a number to the current one.

Parameters:
scaled - the number to add

divide

public void divide(long scaled)
Divide the scaled value by a number.

Parameters:
scaled - the divisor

eq

public boolean eq(ScaledNumber d)
Compares the current instance with another ScaledNumber for equality.

Parameters:
d - the other ScaledNumber to compare to. If this parameter is null then the comparison fails.
Returns:
true iff |this| == |d|

ge

public boolean ge(ScaledNumber d)
Compares the current instance with another ScaledNumber.

Parameters:
d - the other ScaledNumber to compare to
Returns:
true iff this is greater or equal to d

getValue

public long getValue()
Getter for the value.

Returns:
the value

le

public boolean le(ScaledNumber d)
Compares the current instance with another ScaledNumber.

Parameters:
d - the other ScaledNumber to compare to
Returns:
true iff this is less or equal to d

lt

public boolean lt(ScaledNumber d)
Compares the current instance with another ScaledNumber.

Parameters:
d - the other ScaledNumber to compare to
Returns:
true iff |this| < |d|

multiply

public void multiply(long scaled)
Multiply the current value by a scaled number.

Parameters:
scaled - the multiplicant

multiply

public void multiply(long nom,
                     long denom)
Multiply the value by an integer fraction.

length = length * nom / denom

Parameters:
nom - nominator
denom - denominator

negate

public void negate()
Negate the current value.


set

public void set(long scaled)
Set the value to a new one

Parameters:
scaled - the new value

set

public void set(ScaledNumber scaled)
Setter for the value

Parameters:
scaled - the new value

subtract

public void subtract(ScaledNumber scaled)
Subtract a number from the current one.

Parameters:
scaled - the number to subtract

toString

public java.lang.String toString()
Determine the printable representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
the printable representation