Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 08 Mar 2015 20:37:57 +0100
From: magnum <>
Subject: Re: 256/128 bit integer arithmatic

On 2015-03-08 16:26, Sayantan Datta wrote:
> Hi all,
> Is there any way to natively perform 128 bit or 256 bit integer arithmetic,
> such as add, divide, subtract ? Maybe with AVX/SSE registers and using them
> without SIMD?
> Regards,
> Sayantan

gcc provides int128 for 64-bit builds (but not for 32-bit builds). Look
at our mpz_int128.h which mimics GMP but actually uses saturated 128-bit
integer (the latter is a lot faster - but GMP can go way beyond 128 bits).

They are emulated though, probably similar to using hi/lo 64-bit structs.

One caveat is you can't have constants larger than 64-bit. So to load a
128-bit constant you'd need to do something like this

uint128_t foo = 0xabcd0123deadcafeULL << 64 + 0xdeadcafeabcd0123ULL


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.