Boost logo

Boost :

Subject: [boost] [numeric] Is there interest in detecting precision loss?
From: Antony Polukhin (antoshkka_at_[hidden])
Date: 2011-04-28 02:33:06

There have been some requests for detecting precision loss during
conversion from float types to integral types. But the current numeric
converter just rounds the float number.

This proposal provides two classes, that can be used as a
Float2IntRounder in boost::numeric::converter. One of them
determinates, is there any precision loss, the second class
determinates is there precision loss before user supported sign in
decimal part. On precision loss an exception
boost::numeric::precision_loss_error is thrown.

The proposal can be found at

Tests (and usage examples) can be found at

Is there interest in this for Boost? If there is, shall I add documentation?

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