Skip to content

Commit cd13d29

Browse files
committed
CLJCLR-101: part 3: Fix calc of ulong +/* before checking for overflow
1 parent d7b1707 commit cd13d29

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Clojure/Clojure/Lib/Numbers.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3377,19 +3377,17 @@ public static object num(ulong x)
33773377
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "add")]
33783378
public static ulong add(ulong x, ulong y)
33793379
{
3380-
ulong ret = x + y;
33813380
if ( x > UInt64.MaxValue - y)
33823381
throw new ArithmeticException("integer overflow");
3383-
return ret;
3382+
return x + y;;
33843383
}
33853384

33863385
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "add")]
33873386
public static object addP(ulong x, ulong y)
33883387
{
3389-
ulong ret = x + y;
33903388
if (x > UInt64.MaxValue - y)
33913389
return addP((object)x, (object)y);
3392-
return num(ret);
3390+
return num(x + y);
33933391
}
33943392

33953393
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "minus")]

0 commit comments

Comments
 (0)