Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Interger over/under flow in C?

Name: VIPPER 2012-05-01 13:18

Is there a way to implement a portable way of detecting over and underflows in C?

Another thing, my asm code that handles this for now doesnt work either. I cant figure out why not.

asm ("overflow: "
     "xorl %eax, %eax \n"
     "jno O_Ret \n"
     "incl %eax \n"
     "O_Ret: ret\n");

nig_t fuck () {
  nig_t ass = tits + dick;
  if (overflow)
    return piss;
  if (underflow)
    return shit;
  return ass;
}

Now if i could figure out a way for this to work it would only work temporary, as i will need a portable way in the future anyway.

Any help would be appreciated.

Name: Anonymous 2012-05-03 19:13

>>59
You can't compile C code for a non-binary processor because half the language becomes undefined.
This is untrue, please cite from the standard where you found it or I will disregard it.

Secondly, there are no processors in existence today that would even fall into that category.
That is completely inconsequential, C is defined independently of what architectures currently exists.

Hence, in C, for all integer types, ~(unsigned integer type)0 is the maximum value of that type.
This still isn't true, please cite from the standard where you found this or I will disregard it.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List