Class ReusableFloat
java.lang.Object
java.lang.Number
org.web3d.vrml.scripting.ecmascript.builtin.ReusableFloat
- All Implemented Interfaces:
Serializable
/**
An floating point extension of the
Number
abstract base class that allows the user to reset the internal value.
A typical issue with the Javascript runtime is that everywhere it uses object values rather than primitives. With a lot of method calling, that leads to a large amount of garbage being generated. As the runtime only really looks for Number instances rather than specific values, whenever we can, we use this class. That allows us to re use the instances rather than creating them and then throwing them away.
- Version:
- $Revision: 1.2 $
- Author:
- Justin Couch
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleGet the current value as a double.floatGet the current value as a float.intintValue()Get the current value as an integer.longGet the current value as a long.voidsetValue(double val) Set the class to represent the new value.toString()Convert to String.Methods inherited from class java.lang.Number
byteValue, shortValue
-
Constructor Details
-
ReusableFloat
public ReusableFloat(double val) Create a new value based on the given value- Parameters:
val- The first value to use
-
-
Method Details
-
doubleValue
public double doubleValue()Get the current value as a double.- Specified by:
doubleValuein classNumber- Returns:
- The value as a double
-
floatValue
public float floatValue()Get the current value as a float.- Specified by:
floatValuein classNumber- Returns:
- The value as a float
-
intValue
-
longValue
-
toString
-
setValue
public void setValue(double val) Set the class to represent the new value.- Parameters:
val- The new value to use
-