From: Jacques-Henri Jourdan <jacques-henri.jourdan@normalesup.org>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Integer exponentiation and **
Date: Wed, 25 Jan 2017 11:42:54 +0100 [thread overview]
Message-ID: <db230f4f-4268-00a0-87ab-352e5178ea8c@normalesup.org> (raw)
In-Reply-To: <446a88a3-1e93-91a1-0111-f71a8aa24ec2@prepas.org>
Hi,
Concerning integer exponentiation: integers in OCaml are bounded, and
not meant to compute over large integers. This means that exponentiation
will in practice overflow very quickly, and, anyway, there is no
hardware support for exponentiation (meaning that it would be slower
than expected). There are two alternatives : if the base is 2, you can
use bitwise shifts, and, in any case, you can use a large integers
library such as ZArith (1).
Concerning the syntax for floating point exponentiation: I agree that it
is not coherent. I guess that's a matter of taste (as always with
syntax): some prefer typing 2 characters instead of 3. I honestly do not
know if there is any other reason.You can still define the other syntax:
let ( **. ) = ( ** );;
--
JH
(1) https://github.com/ocaml/Zarith
On 01/24/2017 09:23 AM, Yann Salmon wrote:
> Hello,
>
> I am wondering why OCaml does not have an integer exponentiation
> operator and why the floating point exponentiation operator is ( ** )
> and not ( **. ).
>
> Any ideas ?
>
prev parent reply other threads:[~2017-01-25 10:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-24 8:23 Yann Salmon
2017-01-25 10:42 ` Jacques-Henri Jourdan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=db230f4f-4268-00a0-87ab-352e5178ea8c@normalesup.org \
--to=jacques-henri.jourdan@normalesup.org \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox