問題描述
在 C++ 中表示 128 位數字的最佳方式是什么?它的行為應盡可能接近內置數字類型(即支持所有算術運算符等).
What's the best way to represent a 128-bit number in C++? It should behave as closely to the built-in numeric types as possible (i.e. support all the arithmetic operators, etc).
我正在考慮構建一個包含 2 個 64 位或 4 個 32 位數字的類.或者可能只是創建一個 128 位的內存塊并自己做所有事情.
I was thinking of building a class that had 2 64 bit or 4 32 bit numbers. Or possibly just creating a 128 bit block of memory and doing everything myself.
是否有一些更簡單/更標準的方法,或者我自己實施時不太可能搞砸的方法?:)
Is there some easier/more standard way, or something that I'm less likely to screw up when implementing it myself? :)
如果能擴展到 256 位、512 位等就好了...
It would also be nice if it could be extended to 256-bit, 512-bit, etc...
推薦答案
查看已開發的其他庫.在您之前,很多人都想這樣做.:D
Look into other libraries that have been developed. Lots of people have wanted to do this before you. :D
嘗試 bigint C++
這篇關于在 C++ 中表示 128 位數字的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!