-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed bug in the magnitude computation. (thanks to 0jpq0, closes #20)
- Loading branch information
1 parent
69dd519
commit ed83bb8
Showing
3 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Numerics; | ||
|
||
namespace Rationals | ||
{ | ||
internal static class BigIntegerUtils | ||
{ | ||
/// <summary> | ||
/// Returns the number of digits of the given number | ||
/// </summary> | ||
public static int GetNumberOfDigits(BigInteger x) | ||
{ | ||
x = BigInteger.Abs(x); | ||
|
||
var digits = 0; | ||
while (x > 0) | ||
{ | ||
digits++; | ||
x /= 10; | ||
} | ||
|
||
return digits; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters