Loading ...
Sorry, an error occurred while loading the content.

big numbers

Expand Messages
  • lawyer6662001
    Hello, I need to use the library num to make calcul with big numbers but when I enter #open num like it s indicate in the help section of camllight under
    Message 1 of 13 , Jun 22, 2002
    • 0 Attachment
      Hello, I need to use the library "num" to make calcul with big
      numbers but when I enter #open "num" like it's indicate in the help
      section of camllight under windows, camllight answer "Cannot find
      the compiled interface file num.zi.".
      What Can I do?? thanks!

      (sorry for the faults but i'm french...)
    • kenzo_ahikawa
      In interactive session You can use: # open Num;;
      Message 2 of 13 , Jun 22, 2002
      • 0 Attachment
        In interactive session You can use:
        # open Num;;



        --- In ocaml_beginners@y..., "lawyer6662001" <blaireau93@a...> wrote:
        > Hello, I need to use the library "num" to make calcul with big
        > numbers but when I enter #open "num" like it's indicate in the help
        > section of camllight under windows, camllight answer "Cannot find
        > the compiled interface file num.zi.".
        > What Can I do?? thanks!
        >
        > (sorry for the faults but i'm french...)
      • lawyer6662001
        What is interactive session?? Because when I lauch camllight 074 and when i enter #open num ;;, this message appears : Cannot find the compiled interface
        Message 3 of 13 , Jun 22, 2002
        • 0 Attachment
          What is interactive session??
          Because when I lauch camllight 074 and when i enter #open "num";;,
          this message appears : "Cannot find the compiled interface file
          num.zi.".
          And with #open num;; caml answers "syntax error"...
        • kenzo_ahikawa
          ... Interactive session is when you run ocaml and type something and then ... Objective Caml version 3.04 # let sum a b = a + b;; val sum : int - int - int =
          Message 4 of 13 , Jun 22, 2002
          • 0 Attachment
            --- In ocaml_beginners@y..., "lawyer6662001" <blaireau93@a...> wrote:
            > What is interactive session??
            Interactive session is when you run ocaml and type something and then
            ocaml writes an answer:

            --------- example -------
            Objective Caml version 3.04

            # let sum a b = a + b;;
            val sum : int -> int -> int = <fun>
            # sum 5 10;;
            - : int = 15
            #

            ---------- end ----------

            But you can also put your code in a file (.ml or .mli) and than call
            ocaml compliler (ocamlc). If there will be no errors, you get a
            file with binary code.

            > Because when I lauch camllight 074 and when i enter #open "num";;,
            > this message appears : "Cannot find the compiled interface file
            > num.zi.".
            > And with #open num;; caml answers "syntax error"...

            Don't use #open, but open:

            -------- example ---------
            Objective Caml version 3.04

            # #open Num;;
            Toplevel input:
            # #open Num;;
            ^^^^
            Syntax error
            # open Num;;
            #
            ---------- end ------------

            Now should be ok.
          • YAMAGATA yoriyuki
            From: lawyer6662001 Subject: ocaml_beginners ::[] big numbers Date: Sat, 22 Jun 2002 12:25:46 -0000 ... I have no experience on
            Message 5 of 13 , Jun 22, 2002
            • 0 Attachment
              From: "lawyer6662001" <blaireau93@...>
              Subject: "ocaml_beginners"::[] big numbers
              Date: Sat, 22 Jun 2002 12:25:46 -0000

              > What Can I do?? thanks!

              I have no experience on camllight, (Why you use camllight, anyway?
              ocaml works under Windows.) but as the message indicates, camllight
              can not find the file "num.zi". You can check whether "num.zi" is
              installed in the correct location.

              ... OK, nearly no information in my answer. The camllight guru may
              give you better answers.
              --
              Yamagata Yoriyuki
              http://www.mars.sphere.ne.jp/yoriyuki/
            • lawyer6662001
              ok I ve installed ocaml304 and when i write open Num;; open Big_int;; there is no error message. But when I write: let rec fact n = if n
              Message 6 of 13 , Jun 22, 2002
              • 0 Attachment
                ok I've installed ocaml304 and when i write
                open Num;;
                open Big_int;;
                there is no error message.
                But when I write:
                let rec fact n = if n <= 0 then (num_of_int 1) else num_of_int n */
                (fact (n - 1));;
                ocaml answers "Reference to undefined global `Num'"
                Why????????
                Thanks for your answer!
              • YAMAGATA yoriyuki
                From: kenzo_ahikawa Subject: ocaml_beginners ::[] Re: big numbers Date: Sat, 22 Jun 2002 15:31:12 -0000 ... No. lawyer6662001
                Message 7 of 13 , Jun 22, 2002
                • 0 Attachment
                  From: "kenzo_ahikawa" <mw534@...>
                  Subject: "ocaml_beginners"::[] Re: big numbers
                  Date: Sat, 22 Jun 2002 15:31:12 -0000

                  > Now should be ok.

                  No. lawyer6662001 uses camllight (The predecessor of ocaml). In
                  camllight, #open "module-name" is correct.
                  --
                  Yamagata Yoriyuki
                  http://www.mars.sphere.ne.jp/yoriyuki/
                • YAMAGATA yoriyuki
                  From: lawyer6662001 Subject: ocaml_beginners ::[] Re: big numbers Date: Sat, 22 Jun 2002 16:21:05 -0000 ... Because, open only allows
                  Message 8 of 13 , Jun 22, 2002
                  • 0 Attachment
                    From: "lawyer6662001" <blaireau93@...>
                    Subject: "ocaml_beginners"::[] Re: big numbers
                    Date: Sat, 22 Jun 2002 16:21:05 -0000

                    > But when I write:
                    > let rec fact n = if n <= 0 then (num_of_int 1) else num_of_int n */
                    > (fact (n - 1));;
                    > ocaml answers "Reference to undefined global `Num'"
                    > Why????????
                    > Thanks for your answer!

                    Because, "open" only allows you to abbreviate "Num.num_of_int" with
                    "num_of_int", and does not load the library itself. The Num library
                    is not loaded as default.

                    What should you do depends on your platform. If you use "Native Win32
                    port", just do

                    #load "nums.cma"

                    which will load the body of the library.

                    If you use "Cygwin-based port", things become a bit complex. First
                    you have to build the "custom toplevel", which pre-loads necessary C
                    libraries, as

                    $ ocamlmktop -o mytop nums.cma

                    in the command line. After that, you have to use "mytop" instead of
                    "ocaml"

                    Anyways, you'd better read the manual entry of the num library.
                    --
                    Yamagata Yoriyuki
                    http://www.mars.sphere.ne.jp/yoriyuki/
                  • lawyer6662001
                    Thanks a lot, #load nums.cma ;; works fine and there is no error message when i enter the program fo fact. But when i want to calcul fact 40;; ocaml answer -
                    Message 9 of 13 , Jun 22, 2002
                    • 0 Attachment
                      Thanks a lot, #load "nums.cma";; works fine and there is no error
                      message when i enter the program fo fact.
                      But when i want to calcul fact 40;;
                      ocaml answer - : Num.num = Big_int <abstr>
                      Whereas I tried to write:
                      #load "big_int.cmi";;
                      #load "big_int.cmx";;
                      because the file big_int.cma doesn't exist.
                      but ocaml answer these files are "not a bytecode object file."
                      Of course i tried to write open Big_int;; but like you told me,
                      there is no effect...
                      I need to use this libray before monday, please help me!!
                      Thanks.
                    • Alain Frisch
                      ... So what ? If you want to print a value of type Num.num, you can use Num.string_of_num. You can also install a custom printer for values of this type in
                      Message 10 of 13 , Jun 22, 2002
                      • 0 Attachment
                        On Sat, 22 Jun 2002, lawyer6662001 wrote:

                        > Thanks a lot, #load "nums.cma";; works fine and there is no error
                        > message when i enter the program fo fact.
                        > But when i want to calcul fact 40;;
                        > ocaml answer - : Num.num = Big_int <abstr>

                        So what ? If you want to print a value of type Num.num, you can use
                        Num.string_of_num. You can also install a custom printer for values of
                        this type in the toplevel:

                        let print_num ppf x = Format.pp_print_string ppf (Num.string_of_num x);;
                        #install_printer print_num;;


                        Bon courage pour les oraux !

                        -- Alain
                      • lawyer6662001
                        Thanks, string_of_num works. But I have another problem, when I enter this program: let num_digits_of_num x = num_digits_big_int (big_int_of_num x);; ocaml
                        Message 11 of 13 , Jun 22, 2002
                        • 0 Attachment
                          Thanks, string_of_num works. But I have another problem, when I
                          enter this program:
                          let num_digits_of_num x = num_digits_big_int (big_int_of_num x);;
                          ocaml says: Unbound value num_digits_big_int
                          I think the library for big_int is not installed but how install it??
                          Because there is no file named big_int.cma...
                          Thanks

                          (Merci pour les encouragemnts, j'en aurai bien besoin!!!!)
                        • lawyer6662001
                          Sorry i ve just write open big_int;; and it works! Thank you everybody!
                          Message 12 of 13 , Jun 22, 2002
                          • 0 Attachment
                            Sorry i've just write open big_int;; and it works!
                            Thank you everybody!
                          • YAMAGATA yoriyuki
                            From: YAMAGATA yoriyuki Subject: Re: ocaml_beginners ::[] Re: big numbers Date: Sun, 23 Jun 2002 02:05:42 +0900 ... #load
                            Message 13 of 13 , Jun 26, 2002
                            • 0 Attachment
                              From: YAMAGATA yoriyuki <yoriyuki@...>
                              Subject: Re: "ocaml_beginners"::[] Re: big numbers
                              Date: Sun, 23 Jun 2002 02:05:42 +0900

                              > #load "nums.cma"

                              #load "nums.cma";;
                              ^^
                              is correct. Another evidence you had better not to send emails before
                              sleep...
                            Your message has been successfully submitted and would be delivered to recipients shortly.