The problem seems to be that BigNum doesn't provide a from_int64 - this just means you need to pass via a BigInt.

1
2
3
4
5
6
#light
open Microsoft.FSharp.Math

let divide i =
    let bn = BigNum.of_bigint (BigInt.of_int64 i)
    BigNum.to_float (bn / 10000000000000N)

I believe there's still might be a risk of lost of accuracy when you convert from the resulting BigNum to a float (System.Double) - but I'm not certain on this point.

By on 3/3/2008 12:45 AM ()

Thanks Robert :)

As long as there is no loss of accuracy before the recast to double, then i'm fine.

One last Q which is slightly on topic ..

Now that I have a function I can call from C#, what is the best way to package this code so that someone else does not need to have F# installed on their client?

P.S. Nice book btw :)

By on 3/3/2008 1:04 AM ()

Thanks!

Basically you have two options, use the compiler --standalone flag. This will staticly link all types from FSharp.Core.dll into the assembly produced. Alterantively you just distribute the FSharp.Core.dll assembly, it is loaded by the standard .NET loader so you need to make sure its either in the same directory as the application or in the GAC.

I believe the prefered method is currently to distribute the FSharp.Core.dll assembly.

Cheers,
Rob

By on 3/3/2008 2:08 AM ()

Thanks again Rob! :)

Maybe I can finally stop using the GMP MP libs for this kind of operation and work in a pure managed scenario! :D (Though I will probably miss the performance that it brought with it).

It will hopefully offer a more portable solution than working in Matlab also! (Though I do have to profess I prefer Matlab’s notation style).

Just out of interest, which Arrondissement are you in?? I lived in the 8th for 2 years and loved every day! There is just no place that matches Paris for quality of life, I do envy you right now :)

Thanks again,

Ben

By on 3/3/2008 2:23 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper