Boost Users :
Subject: Re: [Boost-users] deleting operators to forbid mixed arithmetic? [multiprecision]
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2017-08-12 12:42:24
From: Boost-users [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Dani Brake via Boost-users
Sent: 12 August 2017 00:54
Cc: Dani Brake
Subject: [Boost-users] deleting operators to forbid mixed arithmetic? [multiprecision]
I'd like to forbid multiplication of Boost.Multiprecision floating point numbers by doubles. Any tips? I think I want to delete a family of operator*s, but am having a hard time coming up with which ones.
University of Wisconsin Eau Claire
Been there, done that â fallen into the big pit awaiting the unwary mixing double and multiprecision â again and againâ¦ L
I think that you donât really want to delete a family of operator*s â what you DO want to get a warning when there is loss of significance, similar to the warning when you fit a double into a float.
Itâs OK to multiply (or other ops) with a double as long as this doesnât lose any bits or digits of precision.
So multiplying by 0.5 is OK, but not by multiplying 0.1 (the multiprecision type needs FP_type(1)/10 to represent 0.1 as accurately as possible for the FP type).
If only the compiler provided a trait bool is_exactly_representable(double) so that a warning could be issuedâ¦
The compiler knows â¦
--- Paul A. Bristow Prizet Farmhouse Kendal UK LA8 8AB +44 (0) 1539 561830
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net