8
8
namespace FacturaE . DataType ;
9
9
10
10
public struct DoubleSixDecimalType
11
- : IComparable , IFormattable , IConvertible , IComparable < double > , IEquatable < double > , IXmlSerializable
11
+ : IComparable , IFormattable , IConvertible , IComparable < decimal > , IEquatable < decimal > , IXmlSerializable
12
12
{
13
- public static readonly DoubleSixDecimalType MaxValue = new ( double . MaxValue ) ;
14
- public static readonly DoubleSixDecimalType MinValue = new ( double . MinValue ) ;
13
+ public static readonly DoubleSixDecimalType MaxValue = new ( decimal . MaxValue ) ;
14
+ public static readonly DoubleSixDecimalType MinValue = new ( decimal . MinValue ) ;
15
15
16
16
public static bool GreaterThan ( DoubleSixDecimalType left , DoubleSixDecimalType right )
17
17
{
@@ -40,87 +40,45 @@ public static bool NotEquals(DoubleSixDecimalType left, DoubleSixDecimalType rig
40
40
41
41
public static DoubleSixDecimalType Parse ( string value )
42
42
{
43
- return new DoubleSixDecimalType ( double . Parse ( value ) ) ;
43
+ return new DoubleSixDecimalType ( decimal . Parse ( value ) ) ;
44
44
}
45
45
46
46
public static bool operator == ( DoubleSixDecimalType left , DoubleSixDecimalType right )
47
47
{
48
- bool equals = false ;
49
-
50
- if ( left . Value == right . Value )
51
- {
52
- equals = true ;
53
- }
54
-
55
- return equals ;
48
+ return left . Value == right . Value ;
56
49
}
57
50
58
51
public static bool operator != ( DoubleSixDecimalType left , DoubleSixDecimalType right )
59
52
{
60
- bool notequals = false ;
61
-
62
- if ( left . Value != right . Value )
63
- {
64
- notequals = true ;
65
- }
66
-
67
- return notequals ;
53
+ return left . Value != right . Value ;
68
54
}
69
55
70
56
public static bool operator > ( DoubleSixDecimalType left , DoubleSixDecimalType right )
71
57
{
72
- bool greater = false ;
73
-
74
- if ( left . Value > right . Value )
75
- {
76
- greater = true ;
77
- }
78
-
79
- return greater ;
58
+ return left . Value > right . Value ;
80
59
}
81
60
82
61
public static bool operator >= ( DoubleSixDecimalType left , DoubleSixDecimalType right )
83
62
{
84
- bool greater = false ;
85
-
86
- if ( left . Value >= right . Value )
87
- {
88
- greater = true ;
89
- }
90
-
91
- return greater ;
63
+ return left . Value >= right . Value ;
92
64
}
93
65
94
66
public static bool operator < ( DoubleSixDecimalType left , DoubleSixDecimalType right )
95
67
{
96
- bool less = false ;
97
-
98
- if ( left . Value < right . Value )
99
- {
100
- less = true ;
101
- }
102
-
103
- return less ;
68
+ return left . Value < right . Value ;
104
69
}
105
70
106
71
public static bool operator <= ( DoubleSixDecimalType left , DoubleSixDecimalType right )
107
72
{
108
- bool less = false ;
109
-
110
- if ( left . Value <= right . Value )
111
- {
112
- less = true ;
113
- }
114
-
115
- return less ;
73
+ return left . Value <= right . Value ;
116
74
}
117
75
118
- public static implicit operator double ( DoubleSixDecimalType x )
76
+ public static implicit operator decimal ( DoubleSixDecimalType x )
119
77
{
120
78
return x . Value ;
121
79
}
122
80
123
- public static implicit operator DoubleSixDecimalType ( double x )
81
+ public static implicit operator DoubleSixDecimalType ( decimal x )
124
82
{
125
83
return new DoubleSixDecimalType ( x ) ;
126
84
}
@@ -131,16 +89,11 @@ public static implicit operator DoubleSixDecimalType(DoubleTwoDecimalType x)
131
89
}
132
90
133
91
[ XmlIgnore ]
134
- public double Value { get ; private set ; }
135
-
136
- public DoubleSixDecimalType ( double value )
137
- {
138
- Value = value ;
139
- }
92
+ public decimal Value { get ; private set ; }
140
93
141
94
public DoubleSixDecimalType ( decimal value )
142
95
{
143
- Value = ( double ) value ;
96
+ Value = value ;
144
97
}
145
98
146
99
public override readonly int GetHashCode ( )
@@ -200,12 +153,12 @@ readonly DateTime IConvertible.ToDateTime(IFormatProvider provider)
200
153
201
154
readonly decimal IConvertible . ToDecimal ( IFormatProvider provider )
202
155
{
203
- return Convert . ToDecimal ( Value ) ;
156
+ return Value ;
204
157
}
205
158
206
159
readonly double IConvertible . ToDouble ( IFormatProvider provider )
207
160
{
208
- return Value ;
161
+ return Convert . ToDouble ( Value ) ;
209
162
}
210
163
211
164
readonly short IConvertible . ToInt16 ( IFormatProvider provider )
@@ -258,12 +211,12 @@ readonly ulong IConvertible.ToUInt64(IFormatProvider provider)
258
211
return Convert . ToUInt64 ( Value ) ;
259
212
}
260
213
261
- readonly int IComparable < double > . CompareTo ( double other )
214
+ readonly int IComparable < decimal > . CompareTo ( decimal other )
262
215
{
263
216
return CompareTo ( other ) ;
264
217
}
265
218
266
- public readonly bool Equals ( double other )
219
+ public readonly bool Equals ( decimal other )
267
220
{
268
221
return Equals ( other ) ;
269
222
}
@@ -277,7 +230,7 @@ public void ReadXml(XmlReader reader)
277
230
{
278
231
if ( reader is not null )
279
232
{
280
- Value = reader . ReadElementContentAsDouble ( ) ;
233
+ Value = reader . ReadElementContentAsDecimal ( ) ;
281
234
}
282
235
}
283
236
0 commit comments