[prev in list] [next in list] [prev in thread] [next in thread]
List: boost
Subject: Re: [boost] Decimal Floating Point Library Beta
From: Matt Borland via Boost <boost () lists ! boost ! org>
Date: 2024-05-16 8:38:20
Message-ID: c9H8cnpdFCfNZ7KrxkY2q_ccmJGMDMO48H5M3GNR3t6H0oCnWwXerXUr5w-YZR5JQcEZPL-_UPS4_s5W4YVbArAZ1ccZYdWnnuwykI84FHA= () mattborland ! com
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
> Thanks for sharing.
>
> During the boost charconv review, it was pointed out that std from_chars has a \
> serious design defect in case of ERANGE, because the return value cannot \
> differentiate between different range errors (value too big, too small, positive / \
> negative, etc.), despite the information being reliably available from the parsing. \
>
> IIRC boost charconv works around this by modifiying the provided value argument, \
> which is forbidden by std.
> Is the same workaround used for decimal? (in which case the documentation should \
> state this). Or should it be seen as an opportunity for fixing the from_chars \
> interface / providing a better error reporting?
Yes the same workaround is applied to decimal. I will make a note in the docs about \
the behavior.
>
> Another note about the documentation: some examples should use literal suffixes
>
> The current way:
>
> constexpr decimal64 b {2, -1}; // 2e-1 or 0.2
>
> is pretty unreadable / ugly. Also, there should be a statement on the differences \
> between:
> constexpr auto b1 = 0.2_DD;
> constexpr auto b2 = decimal64(0.2);
> constexpr auto b3 = decimal64(2, -1);
>
> I expect the first and third ones to be identical and yield precise decimal values, \
> and the second to yield imprecise values, although i could not find a pathological \
> case from quick tests where we would have b2 != b3.
Since it's a limitation of the language 0.2_DD would actually be interpreted as a \
decimal64(0.2L) whereas "0.2"_DD would be equivalent to decimal64(2, -1) so b1 == b2 \
and b2 != b3. I will annotate this potential pitfall in the docs.
Thanks for the feedback.
Matt
["publickey - matt@mattborland.com - 0xC1382EAD.asc" (application/pgp-keys)]
["signature.asc" (application/pgp-signature)]
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic