Reply to post: Re: What am I missing?

Keen to go _ExtInt? LLVM Clang compiler adds support for custom width integers

Phil Endecott

Re: What am I missing?

The issue with e.g. 128-bit integers in C is that there’s no access to the carry flag, so what would be a sequence of 4 add-with-carry instructions (on a 32-bit CPU) ends up much more complicated. (If you’re lucky the compiler will spot what you’re doing and use add-with-carry, but do you know what you have to write in C for it reliably do that?)

uint64_t a,b,c,d,e,f;

....

c = a + b;

bool carry = c<a;

f = d + e + (carry ? 1 : 0);

Is that correct? Does that produce the optimal two-instruction sequence?

.... now write a version for signed arithmetic!

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Biting the hand that feeds IT © 1998–2021