[rust-dev] Appeal for CORRECT, capable, future-proof math, pre-1.0

Owen Shepherd owen.shepherd at e43.eu
Sun Jan 12 11:09:37 PST 2014


On 12 January 2014 19:02, Isaac Dupree <ml at isaac.cedarswampstudios.org>wrote:

> Another sweet spot for a few applications is larger-than-word-sized
> fixed-width types, such as a 128 or 192 bit (u)int.  This is useful for
> code that has to deal with values larger than 64 bits but within, say, 256
> or 512 bits (above this, I think the costs of dynamic allocation and
> non-inlined numeric code become cheap-ish compared to the numeric
> computation and storage costs).  I've done this with C++ templates; it
> works pretty okay; it sure makes GCC/LLVM's register allocator work hard!
>

-Isaac
>
>
A minor variation of "checked_add" (i.e. add_with_carry) would take care of
this. Obviously also need a multiply which returns the two result halves
also.

For implementing bignum arithmetic, this is obviously a point where a
"natural int" type would be best (probably the biggest which fits a single
register)

Owen Shepherd
http://owenshepherd.net | owen.shepherd at e43.eu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140112/5c9d103f/attachment.html>


More information about the Rust-dev mailing list