/
DoubleLiteral.cs
78 lines (71 loc) · 2.43 KB
/
DoubleLiteral.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
namespace CSim.Core.Literals {
using System.Numerics;
using System.Globalization;
/// <summary>
/// Literals of type <see cref="double"/>.
/// </summary>
public class DoubleLiteral: Literal {
/// <summary>
/// Initializes a new instance of the <see cref="T:CSim.Core.Literals.DoubleLiteral"/> class.
/// </summary>
/// <param name="m">The <see cref="Machine"/>.</param>
/// <param name="x">A given double.</param>
public DoubleLiteral(Machine m, object x)
:this( m, System.Convert.ToDouble( x ) )
{
}
/// <summary>
/// Initializes a new instance of the <see cref="T:CSim.Core.Literals.DoubleLiteral"/> class.
/// </summary>
/// <param name="m">The <see cref="Machine"/>.</param>
/// <param name="x">A given double.</param>
public DoubleLiteral(Machine m, double x)
:base( m, x )
{
}
/// <summary>
/// Gets the type of the <see cref="DoubleLiteral"/>.
/// The type is <see cref="CSim.Core.Types.Primitives.Double"/>
/// </summary>
/// <value>The <see cref="AType"/>.</value>
public override AType Type {
get {
return this.Machine.TypeSystem.GetDoubleType();
}
}
/// <summary>
/// The value stored, as an integer value.
/// </summary>
/// <value>The value.</value>
public new double Value {
get {
return (double) base.Value;
}
}
/// <summary>
/// Gets the raw value of the literal, as secquence of bytes.
/// </summary>
/// <value>The raw value.</value>
public override byte[] GetRawValue()
{
return this.Machine.Bytes.FromDoubleToBytes( this.Value );
}
/// <summary>
/// Gets the value as a <see cref="BigInteger"/>.
/// </summary>
/// <returns>The value as <see cref="BigInteger"/>.</returns>
public override BigInteger GetValueAsInteger()
{
return this.Value.ToBigInteger();
}
/// <summary>
/// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:CSim.Core.Literals.DoubleLiteral"/>.
/// </summary>
/// <returns>A <see cref="T:System.String"/> that represents the current <see cref="T:CSim.Core.Literals.DoubleLiteral"/>.</returns>
public override string ToString()
{
return this.Value.ToString( "N2", CultureInfo.InvariantCulture );
}
}
}