[Multiprecision] number conversion to __int128
On 15/05/2020 11:03, A.Dmitrovsky via Boost-users wrote:
Hi, Boost::multiprecision docs [1] mentions that the type parameter of number::convert_to method should be "fundamental", pointing to the list of standard types ('A |number| can be converted to any fundamental (built-in) https://en.cppreference.com/w/cpp/language/types type)'. This is different to number::convert_to reference [2], which states that "Type |T| may be any arithmetic type". Can [unsigned] __int128 be treated as "fundamental" on compilers/platforms which support it?
Yes, it was an oversight - I thought I'd fixed this recently actually, so I might need to investigate some more...
[1] https://www.boost.org/doc/libs/1_73_0/libs/multiprecision/doc/html/boost_mul... [2] https://www.boost.org/doc/libs/1_73_0/libs/multiprecision/doc/html/boost_mul... Regards, Anton
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
From: Boost-users
On 18/05/2020 17:32, A.Dmitrovsky via Boost-users wrote:
Hi,
Strictly speaking, if I get it correct, that passage is about compatibility between different boost::multiprecision types (e.g. mp::int128 to mp::int256 conversion) and tells nothing about being able to convert to some other arithmetic type.
Yes that's correct, like I said I thought I had this fixed, but apparently not fixed enough :( Can you please file a defect report on github so we don't forget? Thanks! John.
So that's why I am here :) Regards, Anton 18.05.2020, 16:51, "Paul A. Bristow via Boost-users"
: From: Boost-users
mailto:boost-users-bounces@lists.boost.org> On Behalf Of A.Dmitrovsky via Boost-users Sent: 15 May 2020 11:03 To: boost-users@lists.boost.org mailto:boost-users@lists.boost.org Cc: A.Dmitrovsky mailto:tdiff@yandex.ru> Subject: [Boost-users] [Multiprecision] number conversion to __int128 Hi,
Boost::multiprecision docs [1] mentions that the type parameter of number::convert_to method should be "fundamental", pointing to the list of standard types ('A number can be converted to any https://en.cppreference.com/w/cpp/language/types type)'. This is different to number::convert_to reference [2], which states that "Type T may be any arithmetic type".
Can [unsigned] __int128 be treated as "fundamental" on compilers/platforms which support it?
[1] https://www.boost.org/doc/libs/1_73_0/libs/multiprecision/doc/html/boost_mul... [2] https://www.boost.org/doc/libs/1_73_0/libs/multiprecision/doc/html/boost_mul...
Does
“ *Interconversions between number types of the same family are allowed and are implicit conversions if no loss of precision is involved, and explicit if it is: …
"
In https://www.boost.org/doc/libs/1_73_0/libs/multiprecision/doc/html/boost_mul...
Not cover your case _uint128 ? and thus allowed for conversion.
Even if the _uint* and _int* types are not fundamental builtin types (regrettably - blame the glacial process of C and C++ standardization and the millstone of C (don't ask) - but they might as well be for most purposes, including this one).
HTH
Paul
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org mailto:Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
participants (3)
-
A.Dmitrovsky
-
John Maddock
-
pbristow@hetp.u-net.com