Boost logo

Boost :

Subject: Re: [boost] iround() and itrunc() in Conceptual Requirements for Real Number Types
From: John Maddock (jz.maddock_at_[hidden])
Date: 2019-01-04 19:49:28

On 04/01/2019 18:24, Matt Pulver via Boost wrote:
> Hello,
> Regarding the page Conceptual Requirements for Real Number Types
> Is it still accurate to list these 2 rows under Standard Library Support
> Requirements?
> - iround(cr1) | int
> - itrunc(cr1) | int
> The motivation in asking this is two-fold:
> 1. I don't see either of these functions listed in the Standard Library.
> Perhaps this is just old documentation, or I am not looking in the right
> place. Instead, I do find lround() and truncl().

I should make it clearer that these are not *std* lib functions -
they're Boost.Math functions, but will be called via ADL so can be in
the same namespace as the number type.

The motivation for these, is that there are many special functions which
require conversion of the real-number-type to an integer as part of
their implementation (when figuring out recurrence relations for
example).  However, conversion of arbitrary number types to integers
can't be guaranteed, and when it does work - as with built in floating
point types - then it's unsafe (overflow etc).  So these functions
provide a customisation point for this conversion.

You may well find that Boost.Math's default versions of these work for
your number type - have you tried it to see?

Best, John.

> 2. One of the design goals of Boost.Autodiff (WIP) is to satisfy all of
> the requirements on this page, and these are the only two which I am unable
> to satisfy for the above reason.
> If someone were to update this page, or otherwise advise on how to
> reconcile, it would be appreciated so that the Boost.Autodiff
> <> library could accurately claim to
> satisfy 100% of Boost's Real Number Type requirements.
> Best regards,
> Matt
> _______________________________________________
> Unsubscribe & other changes:

This email has been checked for viruses by Avast antivirus software.

Boost list run by bdawes at, gregod at, cpdaniel at, john at