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
https://docs.google.com/document/d/1IsA40cq9kYF31jDM_tyIvVNnvC5-uI9-5ez52pzleM8/edit?hl=en&authkey=CKuo7-IE

Tests (and usage examples) can be found at
https://docs.google.com/document/d/1cbYYDcL1t0jbZ7hUFqXODu3VKoWe4_A5IMdXHN5nC9I/edit?hl=en&authkey=CIKs_aoD

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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk