Skip to content

Commit 9c6ed6c

Browse files
Refactor: Remove unnecessary Arithmonym. access inside of Arithmonym. Reassurance: 199 of 199 tests pass.
1 parent f6cb05c commit 9c6ed6c

2 files changed

Lines changed: 22 additions & 22 deletions

File tree

src/GoogolSharp/Modules/ArithmeticOperations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public static Arithmonym Floor(Arithmonym v)
273273

274274
public static Arithmonym operator %(Arithmonym a, Arithmonym b)
275275
{
276-
if (b == Arithmonym.Zero)
276+
if (b == Zero)
277277
throw new DivideByZeroException();
278278

279279
// quotient = Floor(a / b)

src/GoogolSharp/Modules/INumberOperations.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public static bool IsZero(Arithmonym v)
153153

154154
public static Arithmonym MinMagnitude(Arithmonym x, Arithmonym y)
155155
{
156-
if (IsNaN(x) || IsNaN(y)) return Arithmonym.NaN;
156+
if (IsNaN(x) || IsNaN(y)) return NaN;
157157

158158
var ax = Abs(x);
159159
var ay = Abs(y);
@@ -168,7 +168,7 @@ public static Arithmonym MinMagnitude(Arithmonym x, Arithmonym y)
168168

169169
public static Arithmonym MaxMagnitude(Arithmonym x, Arithmonym y)
170170
{
171-
if (IsNaN(x) || IsNaN(y)) return Arithmonym.NaN;
171+
if (IsNaN(x) || IsNaN(y)) return NaN;
172172

173173
var ax = Abs(x);
174174
var ay = Abs(y);
@@ -253,25 +253,25 @@ public static bool TryConvertFromSaturating<TFrom>(TFrom value, out Arithmonym r
253253
// Handle NaN
254254
if (TFrom.IsNaN(value))
255255
{
256-
result = Arithmonym.NaN; // or default if you don’t support NaN
256+
result = NaN; // or default if you don’t support NaN
257257
return true;
258258
}
259259

260260
// Handle Infinity
261261
if (TFrom.IsInfinity(value))
262262
{
263-
result = TFrom.IsNegative(value) ? Arithmonym.MinValue : Arithmonym.MaxValue;
263+
result = TFrom.IsNegative(value) ? MinValue : MaxValue;
264264
return true;
265265
}
266266

267267
// Double
268268
if (typeof(TFrom) == typeof(double))
269269
{
270270
double original = (double)(object)value;
271-
if (original > (double)Arithmonym.MaxValue)
272-
result = Arithmonym.MaxValue;
273-
else if (original < (double)Arithmonym.MinValue)
274-
result = Arithmonym.MinValue;
271+
if (original > (double)MaxValue)
272+
result = MaxValue;
273+
else if (original < (double)MinValue)
274+
result = MinValue;
275275
else
276276
result = new Arithmonym(original);
277277
return true;
@@ -281,10 +281,10 @@ public static bool TryConvertFromSaturating<TFrom>(TFrom value, out Arithmonym r
281281
if (typeof(TFrom) == typeof(Float128))
282282
{
283283
var original = (Float128)(object)value;
284-
if (original > (Float128)Arithmonym.MaxValue)
285-
result = Arithmonym.MaxValue;
286-
else if (original < (Float128)Arithmonym.MinValue)
287-
result = Arithmonym.MinValue;
284+
if (original > (Float128)MaxValue)
285+
result = MaxValue;
286+
else if (original < (Float128)MinValue)
287+
result = MinValue;
288288
else
289289
result = new Arithmonym(original);
290290
return true;
@@ -315,7 +315,7 @@ public static bool TryConvertFromTruncating<TFrom>(TFrom value, out Arithmonym r
315315
// Handle NaN
316316
if (TFrom.IsNaN(value))
317317
{
318-
result = Arithmonym.NaN; // or default if you don’t support NaN
318+
result = NaN; // or default if you don’t support NaN
319319
return true;
320320
}
321321

@@ -330,10 +330,10 @@ public static bool TryConvertFromTruncating<TFrom>(TFrom value, out Arithmonym r
330330
if (typeof(TFrom) == typeof(double))
331331
{
332332
double original = (double)(object)value;
333-
if (original > (double)Arithmonym.MaxValue)
334-
result = Arithmonym.MaxValue; // truncate down
335-
else if (original < (double)Arithmonym.MinValue)
336-
result = Arithmonym.MinValue; // truncate up
333+
if (original > (double)MaxValue)
334+
result = MaxValue; // truncate down
335+
else if (original < (double)MinValue)
336+
result = MinValue; // truncate up
337337
else
338338
result = new Arithmonym(original);
339339
return true;
@@ -343,10 +343,10 @@ public static bool TryConvertFromTruncating<TFrom>(TFrom value, out Arithmonym r
343343
if (typeof(TFrom) == typeof(Float128))
344344
{
345345
var original = (Float128)(object)value;
346-
if (original > (Float128)Arithmonym.MaxValue)
347-
result = Arithmonym.MaxValue;
348-
else if (original < (Float128)Arithmonym.MinValue)
349-
result = Arithmonym.MinValue;
346+
if (original > (Float128)MaxValue)
347+
result = MaxValue;
348+
else if (original < (Float128)MinValue)
349+
result = MinValue;
350350
else
351351
result = new Arithmonym(original);
352352
return true;

0 commit comments

Comments
 (0)