csharpfftfsharpintegrationinterpolationlinear-algebramathdifferentiationmatrixnumericsrandomregressionstatisticsmathnet
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
794 B
28 lines
794 B
namespace System.Numerics
|
|
|
|
open System
|
|
|
|
[<AutoOpen>]
|
|
module BigIntegerExtensions =
|
|
//
|
|
let rec private parseImpl (str : string) len acc i =
|
|
if i = len then
|
|
acc
|
|
else
|
|
let d = int str.[i] - int '0'
|
|
if 0 <= d && d <= 9 then
|
|
parseImpl str len (10I * acc + (bigint d)) (i + 1)
|
|
else
|
|
raise <| FormatException ("The value could not be parsed.")
|
|
|
|
type BigInteger with
|
|
//
|
|
static member Parse (str : string) =
|
|
let len = str.Length
|
|
if len = 0 then
|
|
raise <| FormatException ("The value could not be parsed.")
|
|
|
|
if str.[0] = '-' then
|
|
-(parseImpl str len 0I 1)
|
|
else
|
|
parseImpl str len 0I 0
|
|
|