Class DoubleValue
DoubleValue can operate in two modes based on Constants.getAddressSize():
- Single-word mode: Uses one Value component (index 0)
- Double-word mode: Uses two Value components (index 0 = MSB, index 1 = LSB)
The class provides automatic increment functionality useful for pointer arithmetic and address calculations, with proper overflow handling across word boundaries.
- Since:
- 1.0
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new DoubleValue with all components initialized to undefined values.DoubleValue(int n) Constructs a new DoubleValue from a single integer value.DoubleValue(Value v1) Constructs a new DoubleValue by copying from another Value.DoubleValue(Value v1, Value v2) Constructs a new DoubleValue from two separate Value components. -
Method Summary
Modifier and TypeMethodDescriptionPerforms addition with another value.intget()Gets the numeric value as an integer.Returns the current value and then increments this DoubleValue.intGets the value interpreted as a signed integer.intGets the value interpreted as an unsigned integer.Performs multiplication with another value.set(int n) Sets this value to the specified numeric value.voidSets this value to match another value.Performs subtraction with another value.toString()Returns a string representation of this value.static Stringunset()Methods inherited from class io.matita08.value.Value
create, create, equals, getNew, getNewAddress, isUndefined
-
Constructor Details
-
DoubleValue
public DoubleValue()Constructs a new DoubleValue with all components initialized to undefined values. The number of components depends on the current address size configuration. -
DoubleValue
public DoubleValue(int n) Constructs a new DoubleValue from a single integer value. For double-word mode, the value is split across MSB and LSB components. For single-word mode, the entire value is stored in component 0.- Parameters:
n- the integer value to store
-
DoubleValue
Constructs a new DoubleValue by copying from another Value. If the source is a DoubleValue, copies its components. Otherwise, stores the source value in component 0.- Parameters:
v1- the value to copy from
-
DoubleValue
Constructs a new DoubleValue from two separate Value components. This constructor is only valid for double-word mode.- Parameters:
v1- the value for component 0 (MSB)v2- the value for component 1 (LSB)- Throws:
IllegalArgumentException- if either parameter is already a DoubleValue
-
-
Method Details
-
unset
For DoubleValue, returns a string representation of undefined state with question marks for each address component.
-
set
Sets this value to the specified numeric value. The behavior depends on the concrete value type - some types may return a new instance while others modify the current instance.For DoubleValue, creates a new DoubleValue with the specified numeric value.
-
set
Sets this value to match another value. The default implementation extracts the numeric value and callsValue.set(int). Subclasses may override this for more sophisticated value copying.For DoubleValue, updates the internal components based on the source value type. Handles DoubleValue-to-DoubleValue copying, undefined value initialization, and SingleValue integration with intelligent component selection.
-
add
Performs addition with another value. The operation is performed using the appropriate numeric representation and may handle sign extension or overflow based on the value types involved.For DoubleValue, performs addition by creating a new DoubleValue with the sum of both operands.
-
sub
Performs subtraction with another value. The operation is performed using the appropriate numeric representation and may handle sign extension or underflow based on the value types involved.For DoubleValue, performs subtraction by creating a new DoubleValue with the difference of both operands.
-
mul
Performs multiplication with another value. The operation is performed using the appropriate numeric representation and may handle overflow based on the value types involved.For DoubleValue, multiplication is not intended to be used. This method throws an AssertionError if called.
- Specified by:
mulin classValue- Parameters:
v2- the value to multiply with this value- Returns:
- a new value containing the product
- Throws:
AssertionError- always, as this method is not intended for use
-
get
public int get()Gets the numeric value as an integer. The default implementation delegates toValue.getUnsigned().For DoubleValue, combines all components into a single integer. In double-word mode, calculates MSB * ValueMax + LSB. In single-word mode, returns the value of component 0.
-
getSigned
public int getSigned()Gets the value interpreted as a signed integer. The sign interpretation depends on the value type and configuration.For DoubleValue, delegates to
get()as signed interpretation is the same as unsigned for the composite value. -
getUnsigned
public int getUnsigned()Gets the value interpreted as an unsigned integer. All negative representations are treated as positive values.For DoubleValue, delegates to
get()for unsigned interpretation.- Specified by:
getUnsignedin classValue- Returns:
- the value as an unsigned integer
-
getAndInc
Returns the current value and then increments this DoubleValue. This method is useful for pointer arithmetic where you need both the current address and want to advance to the next location.Increment behavior:
- Single-word mode: Increments component 0 with overflow to 0
- Double-word mode: Increments LSB, carries over to MSB on overflow
- Returns:
- a copy of this DoubleValue before incrementing
-
toString
Returns a string representation of this value. The representation uses the radix specified byConstants.getRadix()and may show special indicators for undefined values.For DoubleValue, returns a string representation that shows undefined components as "?" and combines defined components appropriately based on the current radix setting.
-