forked from ln-dotnet/ln.json
43 lines
704 B
C#
43 lines
704 B
C#
using System;
|
|
namespace sharp.json
|
|
{
|
|
public class JSONNumber: JSON
|
|
{
|
|
Int64 intValue;
|
|
Double doubleValue;
|
|
|
|
public JSONNumber()
|
|
:base(JSONTypes.Number)
|
|
{
|
|
intValue = 0;
|
|
doubleValue = Double.NaN;
|
|
}
|
|
public JSONNumber(Int64 i)
|
|
:base(JSONTypes.Number)
|
|
{
|
|
intValue = i;
|
|
doubleValue = Double.NaN;
|
|
}
|
|
public JSONNumber(Double d)
|
|
:base(JSONTypes.Number)
|
|
{
|
|
intValue = (Int64)d;
|
|
doubleValue = d;
|
|
}
|
|
|
|
public override string prettyPrint(int d = 0)
|
|
{
|
|
if (Double.IsNaN(doubleValue)){
|
|
return this.intValue.ToString();
|
|
} else {
|
|
return this.doubleValue.ToString();
|
|
}
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return this.prettyPrint(0);
|
|
}
|
|
}
|
|
}
|