-
Notifications
You must be signed in to change notification settings - Fork 3
/
PyFloat.cs
47 lines (38 loc) · 1.06 KB
/
PyFloat.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
using System.IO;
namespace eveMarshal
{
public class PyFloat : PyObject
{
public double Value { get; private set; }
public PyFloat()
: base(PyObjectType.Float)
{
}
public PyFloat(double value)
: base(PyObjectType.Float)
{
Value = value;
}
public override void Decode(Unmarshal context, MarshalOpcode op, BinaryReader source)
{
if (op == MarshalOpcode.RealZero)
Value = 0.0d;
else
Value = source.ReadDouble();
}
protected override void EncodeInternal(BinaryWriter output)
{
if (Value == 0.0d)
output.WriteOpcode(MarshalOpcode.RealZero);
else
{
output.WriteOpcode(MarshalOpcode.Real);
output.Write(Value);
}
}
public override string ToString()
{
return "<" + Value + ">";
}
}
}