braju.com
Java printf & scanf (beta)

com.braju.beta.lang
Class DoubleVariable

java.lang.Object
  |
  +--java.lang.Number
        |
        +--com.braju.beta.lang.NumberVariable
              |
              +--com.braju.beta.lang.DoubleVariable
All Implemented Interfaces:
java.io.Serializable, Variable

public final class DoubleVariable
extends NumberVariable
implements Variable

Wraps a double and provides methods to convert the value to and from several datatypes [JDK1.0.2 compatible].

See Also:
Serialized Form

Field Summary
static int ALWAYS_PERIOD
          When converting a double to a string, this constant indicates that the result should always contain a period even if there is no digits following the period [...].
static double MAX_VALUE
          The largest positive value of type double.
static double MIN_VALUE
          The smallest positive value of type double.
static double NaN
          A NaN (Not a Number) value of type double.
static double NEGATIVE_INFINITY
          The negative infinity of type double.
static double POSITIVE_INFINITY
          The positive infinity of type double.
static int SIGNIFICANT_PRECISION
          When converting a double to a string with specified precision, this constant indicates that the value of the precision specifies the number of significants [...].
static int SUPPRESS_PERIOD
          When converting a double to a string, this constant indicates that the result should suppress the period if there is no digits following the period [...].
static int TRAILING_ZEROS
          When converting a double to a string, this constant specifies that result should contain leading zeros.
static java.lang.Class TYPE
          The class of this static object [...].
 
Fields inherited from class com.braju.beta.lang.NumberVariable
ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, LEADING_ZEROS, NO_FLAGS, SIGN_ALWAYS, SIGN_MINUS, SIGN_SPACE
 
Constructor Summary
DoubleVariable()
           
DoubleVariable(double d)
          Wraps a double into an object just like java.lang.Double does, but provides some additional methods.
 
Method Summary
 byte byteValue()
          Return the wrapped value as a byte.
 double doubleValue()
          Return the wrapped value as a double.
 boolean equals(java.lang.Object obj)
          Compare this object with another object [...].
 float floatValue()
          Return the wrapped value as a float.
 java.lang.Object get()
           
 int hashCode()
          Return a hash code for this object based on the wrapped value.
 int intValue()
          Return the wrapped value as an int.
 long longValue()
          Return the wrapped value as a long.
static void main(java.lang.String[] args)
           
static DoubleVariable[] newArray(int length)
          Creates an array of length instance of this class.
 void set(double d)
          Set a new value [...].
 void set(java.lang.Object o)
           
 short shortValue()
          Return the wrapped value as a short.
static java.lang.String toScientificString(double d, int minWidth, int precision, int flags)
          Convert a double into a string in scientific format using specified minimum width, precision and control flags [...].
 java.lang.String toString()
          Return the wrapped double as a String.
static java.lang.String toString(double d)
          Convert a double into a string [...].
static java.lang.String toString(double d, int minWidth, int precision, int flags)
          Convert a double into a string using specified minimum width, precision and control flags [...].
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_VALUE

public static final double MIN_VALUE
The smallest positive value of type double.

MAX_VALUE

public static final double MAX_VALUE
The largest positive value of type double.

NEGATIVE_INFINITY

public static final double NEGATIVE_INFINITY
The negative infinity of type double.

POSITIVE_INFINITY

public static final double POSITIVE_INFINITY
The positive infinity of type double.

NaN

public static final double NaN
A NaN (Not a Number) value of type double.

TYPE

public static final java.lang.Class TYPE
The class of this static object [...]. Provides a convenient way to check or compare the type.

TRAILING_ZEROS

public static final int TRAILING_ZEROS
When converting a double to a string, this constant specifies that result should contain leading zeros.

SIGNIFICANT_PRECISION

public static final int SIGNIFICANT_PRECISION
When converting a double to a string with specified precision, this constant indicates that the value of the precision specifies the number of significants [...]. By default does the precision specfify number of decimals.

ALWAYS_PERIOD

public static final int ALWAYS_PERIOD
When converting a double to a string, this constant indicates that the result should always contain a period even if there is no digits following the period [...]. The result of a conversion using this control constans could be "1234.".

SUPPRESS_PERIOD

public static final int SUPPRESS_PERIOD
When converting a double to a string, this constant indicates that the result should suppress the period if there is no digits following the period [...]. The result of a conversion using this control constans could be "1234".
Constructor Detail

DoubleVariable

public DoubleVariable()

DoubleVariable

public DoubleVariable(double d)
Wraps a double into an object just like java.lang.Double does, but provides some additional methods.
Method Detail

newArray

public static DoubleVariable[] newArray(int length)
Creates an array of length instance of this class.

set

public void set(double d)
Set a new value [...]. This is better than creating a new object all the time.

set

public void set(java.lang.Object o)
Specified by:
set in interface Variable
Overrides:
set in class NumberVariable

get

public java.lang.Object get()
Specified by:
get in interface Variable
Overrides:
get in class NumberVariable

byteValue

public byte byteValue()
Return the wrapped value as a byte.
Overrides:
byteValue in class java.lang.Number

shortValue

public short shortValue()
Return the wrapped value as a short.
Overrides:
shortValue in class java.lang.Number

intValue

public int intValue()
Return the wrapped value as an int.
Overrides:
intValue in class java.lang.Number

longValue

public long longValue()
Return the wrapped value as a long.
Overrides:
longValue in class java.lang.Number

floatValue

public float floatValue()
Return the wrapped value as a float.
Overrides:
floatValue in class java.lang.Number

doubleValue

public double doubleValue()
Return the wrapped value as a double.
Overrides:
doubleValue in class java.lang.Number

toString

public static java.lang.String toString(double d)
Convert a double into a string [...]. Default precision is 7 decimals.

toString

public static java.lang.String toString(double d,
                                        int minWidth,
                                        int precision,
                                        int flags)
Convert a double into a string using specified minimum width, precision and control flags [...]. With the control flags you can specify the alignment and control the sign. The precision parameters is either number of digits after the period or number of significant, depending on the control flags (SIGNIFICANT_PRECISION).

toString

public java.lang.String toString()
Return the wrapped double as a String.
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Compare this object with another object [...]. If the objects are equal (in some sence) true is returned, otherwise false. If the object is compare to a null-object, false is always returned. Not all types of objects can be compared with a DoubleVariable object. Currently DoubleVariable objects can be compared with all java.lang.Number objects including all com.braju.lang.NumberVariable objects.
Overrides:
equals in class java.lang.Object

toScientificString

public static java.lang.String toScientificString(double d,
                                                  int minWidth,
                                                  int precision,
                                                  int flags)
Convert a double into a string in scientific format using specified minimum width, precision and control flags [...]. Scientific format is for instance 4.502e-03. With the control flags you can specify the alignment and control the sign. The precision parameters is either number of digits after the period or number of significant, depending on the control flags (SIGNIFICANT_PRECISION).

hashCode

public int hashCode()
Return a hash code for this object based on the wrapped value.
Overrides:
hashCode in class java.lang.Object

main

public static void main(java.lang.String[] args)

braju.com
Java printf & scanf (beta)

Copyright 1997-2000, Henrik Bengtsson.