简体   繁体   中英

Input a 128-bit value c++ boost

I use int128_t in boost, multiprecision library.

When I write int128_t number = 265252859812191058636308480000000; I have a mistake, that constant is too long.

How can I input 128-bit value correctly? For example:

AF5228967057FE1CB84B92511BE89A47 in int128_t?

As @jonathon-reinhart said, a bit of reading the boost documentation will lead you to an answer.

Specifically, http://www.boost.org/doc/libs/1_55_0/libs/multiprecision/doc/html/boost_multiprecision/tut/conversions.html shows how to construct multi precision types from (say) a string.

You can't construct it from a literal, because literals are only built-in types. Unless you are using C++11 and you have a compiler which supports user-defined literal conversions, in which case http://www.boost.org/doc/libs/1_55_0/libs/multiprecision/doc/html/boost_multiprecision/tut/lits.html describes how to use those.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM