From 5802f3ca1fc8ac79c199767361e63730429c7f45 Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Wed, 11 Dec 2019 20:20:11 -0600 Subject: [PATCH] Changed FloatingPoint underlying type to Decimal --- IPA.Loader/Config/Data/Primitives.cs | 4 ++-- IPA.Loader/Config/Data/Value.cs | 10 +++++----- IPA.Loader/Config/Providers/JsonConfigProvider.cs | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/IPA.Loader/Config/Data/Primitives.cs b/IPA.Loader/Config/Data/Primitives.cs index 1d1bd813..c03b3c90 100644 --- a/IPA.Loader/Config/Data/Primitives.cs +++ b/IPA.Loader/Config/Data/Primitives.cs @@ -50,14 +50,14 @@ namespace IPA.Config.Data /// /// A representing a floating point value. This may hold a - /// 's worth of data. + /// 's worth of data. /// public sealed class FloatingPoint : Value { /// /// The actual value fo this object. /// - public double Value { get; set; } + public decimal Value { get; set; } /// /// Coerces this into an . diff --git a/IPA.Loader/Config/Data/Value.cs b/IPA.Loader/Config/Data/Value.cs index 8b397a8e..2e0e4eb7 100644 --- a/IPA.Loader/Config/Data/Value.cs +++ b/IPA.Loader/Config/Data/Value.cs @@ -76,15 +76,15 @@ namespace IPA.Config.Data /// /// the value to wrap /// a wrapping - /// - public static FloatingPoint From(double val) => Float(val); + /// + public static FloatingPoint From(decimal val) => Float(val); /// - /// Creates a new wrapping a . + /// Creates a new wrapping a . /// /// the value to wrap /// a wrapping - /// - public static FloatingPoint Float(double val) => new FloatingPoint { Value = val }; + /// + public static FloatingPoint Float(decimal val) => new FloatingPoint { Value = val }; /// /// Creates a new wrapping a . diff --git a/IPA.Loader/Config/Providers/JsonConfigProvider.cs b/IPA.Loader/Config/Providers/JsonConfigProvider.cs index 1525ef04..4336943e 100644 --- a/IPA.Loader/Config/Providers/JsonConfigProvider.cs +++ b/IPA.Loader/Config/Providers/JsonConfigProvider.cs @@ -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;