bigint literals have a big I on the end, e.g

mul 8798643I 87987987I

You can also use overloaded operators:

8798643I * 87987987I

-- don

By on 11/26/2006 2:10 PM ()

Thanks Don for the very quick answer !

An other question, is there a mod function for BigInt ?

Here is what I am doing :(two versions) :

let rec power_mod x y n =
if y = 0 then 1
else (
let a = power_mod ((x*x) mod n) (y/2) n in
if y mod 2 = 0 then a
else (a*x) mod n
);;

let power_mod_tail_recursion x y n =
let rec iter x y n acc =
if y = 0 then acc
else if y mod 2 = 0 then iter ((x*x) mod n) (y/2) n acc
else iter ((x*x) mod n) (y/2) n ((acc*x) mod n)
in
iter x y n 1;;

By on 11/26/2006 2:27 PM ()

Use BigInt.rem. The naming of some of the functions under BigInt are a little non-standard (e.g. we have both "rem" and "divmod"), though generally intuitive. Also, the operator (%) and (mod) - normally identical - are not overlaoded for BigInt and BigNum, for no particularly good reason. We'll address that.

-- Don

By on 11/26/2006 3:00 PM ()

ok thanks a lot !

By on 11/27/2006 7:26 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