mercredi 4 mars 2015

Getting the high part of 64 bit integer multiplication


In C++, say that:



uint64_t i;
uint64_t j;


then i * j will yield an uint64_t that has as value the lower part of the multiplication between i and j, i.e., (i * j) mod 2^64. Now, what if I wanted the higher part of the multiplication? I know that there exists an assembly instruction do to something like that when using 32 bit integers, but I am not familiar at all with assembly, so I was hoping for help.


What is the most efficient way to make something like:



uint64_t k = mulhi(i, j);



Aucun commentaire:

Enregistrer un commentaire