Boost logo

Boost :

Subject: Re: [boost] [review] Multiprecision review scheduled for June 8th - 17th, 2012
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2012-06-04 02:06:38


Le 04/06/12 01:09, Christopher Kormanyos a écrit :
>> I would expect the implicit conversion from cpp_dec_float_50 to
>> cpp_dec_float_100 to be found here, but I don't know why the compiler
>> don't find it.
> Because cpp_dec_float_50 and cpp_dec_float_100 are *different types*.
> The compiler does not find binary arithmetic involving these two different
> types because it does not exist. We decided not to support it.
>
> This design choice has both advantages as well as disadvantages.
> In our opinion, the advantages outweigh the disadvantages.
>
> <snip>
>
>>>> Yes but it round while converting 100 digits to 50, and this should be
>>>> documented.
>>> No. I wish we *would* already have rounding in these cases.
>>> But we don't! In fact, the class constructor has a TODO-style comment
>>> indicating that it does not round.
>> Well, I don't know how a type that has less bytes to store the
>> conversion could do it without rounding. Maybe you mean that you have
>> taken just the first 50 digits, but this is a kind of rounding.
> Yes, that's exactly what I mean!
>
> My implementation takes the first 50 digits plus
> the guard digits of the 100 digit type and copies these to the
> 50 digit type. I don't call that rounding. But you do. Sorry
> about the confusion.
>
>>> Conversion to another digit range does not round.
>>> Since rounding occurs when printing the number,
>>> and because there are guard digits, you must
>>> be experiencing the "illusion" of rounding via
>>> a rounded printout.
>> Hmm, I should be missing something trivial :(
>>
> No, you are right. Rather, I did not understand your questions.
> Based on your continued clarifications and my previous
> misunderstanding, you have got it. For cpp_dec-float, rounding
> is truncation.
No I was wrong and missing yet something important. The example I was
using let me thought that a rounding was done because all the digits
were fractional, but if there were integral the operation should be a
truncation taking the most significant digits.
> The exception is conversion of cpp_dec_float to string,
> which rounds. But I forgot if it rounds toward zero, nearest
> or infinity. I will look it up and tell you.
>
Sorry for the noise.

Vicente


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