Class NumberValue
Represents a numeric value (integer or floating-point) in the virtual machine.
Implements
Inherited Members
Namespace: VM.Core.ValueTypes
Assembly: VM.dll
Syntax
public class NumberValue : IValue
Remarks
Can store either int or float values internally and provides appropriate conversions.
Constructors
NumberValue(int)
Initializes a new integer NumberValue.
Declaration
public NumberValue(int value)
Parameters
Type | Name | Description |
---|---|---|
int | value | The integer value to store. |
NumberValue(float)
Initializes a new floating-point NumberValue.
Declaration
public NumberValue(float value)
Parameters
Type | Name | Description |
---|---|---|
float | value | The float value to store. |
Properties
Raw
Gets the raw underlying value as an object.
Declaration
public object Raw { get; }
Property Value
Type | Description |
---|---|
object |
TypeName
Gets the type name of this value.
Declaration
public string TypeName { get; }
Property Value
Type | Description |
---|---|
string |
Methods
AsBool()
Converts the value to a boolean.
Declaration
public bool AsBool()
Returns
Type | Description |
---|---|
bool | The boolean representation of the value. |
AsFloat()
Converts the value to a floating-point number.
Declaration
public float AsFloat()
Returns
Type | Description |
---|---|
float | The converted float value. |
Exceptions
Type | Condition |
---|---|
InvalidCastException | Thrown when conversion is not possible. |
AsInt()
Converts the value to an integer.
Declaration
public int AsInt()
Returns
Type | Description |
---|---|
int | The converted integer value. |
Exceptions
Type | Condition |
---|---|
InvalidCastException | Thrown when conversion is not possible. |
AsString()
Converts the value to a string.
Declaration
public string AsString()
Returns
Type | Description |
---|---|
string | The string representation of the value. |
ToString()
Returns the string representation of the number.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string |