bearophile <bearophileh...@lycos.com> wrote:

Simen kjaeraas:

With floating-point numbers, the above solution does not always work.

The type is known at compile time, so you can split the algorithm in two with a "static if", and do something else if it's an integral type.

Absolutely. However, in this example doubles were used.

Also, though it may be doable for integers, other types may also want
that optimization (BigInt comes to mind). A behavesAsIntegral!T might
fix that.

--
Simen

Reply via email to