lundi 7 décembre 2015

Behaviour of negative zero on a one's complement architecture?

Consider the following code on a one's complement architecture:

int zero = 0;
int negzero = -0;
std::cout<<(negzero < zero)<<std::endl;
std::cout<<(negzero <= zero)<<std::endl;
std::cout<<(negzero == zero)<<std::endl;
std::cout<<(~negzero)<<(~zero)<<std::endl;
std::cout<<(1 << negzero)<<std::endl;
std::cout<<(1 >> negzero)<<std::endl;

  • What output would the code produce?
  • What lines are defined by the standard, what lines are implementation dependent, and what lines are undefined behaviour?

Aucun commentaire:

Enregistrer un commentaire