Browse Source

Changed FloatingPoint underlying type to Decimal

pull/46/head
Anairkoen Schno 4 years ago
parent
commit
5802f3ca1f
3 changed files with 10 additions and 10 deletions
  1. +2
    -2
      IPA.Loader/Config/Data/Primitives.cs
  2. +5
    -5
      IPA.Loader/Config/Data/Value.cs
  3. +3
    -3
      IPA.Loader/Config/Providers/JsonConfigProvider.cs

+ 2
- 2
IPA.Loader/Config/Data/Primitives.cs View File

@ -50,14 +50,14 @@ namespace IPA.Config.Data
/// <summary>
/// A <see cref="Value"/> representing a floating point value. This may hold a
/// <see cref="double"/>'s worth of data.
/// <see cref="decimal"/>'s worth of data.
/// </summary>
public sealed class FloatingPoint : Value
{
/// <summary>
/// The actual value fo this <see cref="FloatingPoint"/> object.
/// </summary>
public double Value { get; set; }
public decimal Value { get; set; }
/// <summary>
/// Coerces this <see cref="FloatingPoint"/> into an <see cref="Integer"/>.


+ 5
- 5
IPA.Loader/Config/Data/Value.cs View File

@ -76,15 +76,15 @@ namespace IPA.Config.Data
/// </summary>
/// <param name="val">the value to wrap</param>
/// <returns>a <see cref="FloatingPoint"/> wrapping <paramref name="val"/></returns>
/// <seealso cref="Float(double)"/>
public static FloatingPoint From(double val) => Float(val);
/// <seealso cref="Float(decimal)"/>
public static FloatingPoint From(decimal val) => Float(val);
/// <summary>
/// Creates a new <see cref="FloatingPoint"/> wrapping a <see cref="double"/>.
/// Creates a new <see cref="FloatingPoint"/> wrapping a <see cref="decimal"/>.
/// </summary>
/// <param name="val">the value to wrap</param>
/// <returns>a <see cref="FloatingPoint"/> wrapping <paramref name="val"/></returns>
/// <seealso cref="From(double)"/>
public static FloatingPoint Float(double val) => new FloatingPoint { Value = val };
/// <seealso cref="From(decimal)"/>
public static FloatingPoint Float(decimal val) => new FloatingPoint { Value = val };
/// <summary>
/// Creates a new <see cref="Value"/> wrapping a <see cref="bool"/>.


+ 3
- 3
IPA.Loader/Config/Providers/JsonConfigProvider.cs View File

@ -85,9 +85,9 @@ namespace IPA.Config.Providers
else return Value.Integer(0);
case JTokenType.Float:
val = (tok as JValue).Value;
if (val is decimal dec) return Value.Float((double)dec);
else if (val is double dou) return Value.Float(dou);
else if (val is float flo) return Value.Float(flo);
if (val is decimal dec) return Value.Float(dec);
else if (val is double dou) return Value.Float((decimal)dou);
else if (val is float flo) return Value.Float((decimal)flo);
else return Value.Float(0); // default to 0 if something breaks
case JTokenType.Date:
val = (tok as JValue).Value;


Loading…
Cancel
Save