* [Caml-list] Integer exponentiation and **
@ 2017-01-24 8:23 Yann Salmon
2017-01-25 10:42 ` Jacques-Henri Jourdan
0 siblings, 1 reply; 2+ messages in thread
From: Yann Salmon @ 2017-01-24 8:23 UTC (permalink / raw)
To: caml-list
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 ?
--
Cordialement,
Yann Salmon
Informatique
MPSI, PCSI, MP*, PC*
Descartes - Tours
<http://pro.yannsalmon.fr/>
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] Integer exponentiation and **
2017-01-24 8:23 [Caml-list] Integer exponentiation and ** Yann Salmon
@ 2017-01-25 10:42 ` Jacques-Henri Jourdan
0 siblings, 0 replies; 2+ messages in thread
From: Jacques-Henri Jourdan @ 2017-01-25 10:42 UTC (permalink / raw)
To: caml-list
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 ?
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-01-25 10:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-24 8:23 [Caml-list] Integer exponentiation and ** Yann Salmon
2017-01-25 10:42 ` Jacques-Henri Jourdan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox