OT Ceckarsky kviz II

Pavel Troller patrol@sinus.cz
Čtvrtek Březen 5 19:52:24 CET 2009


Zdravim,

Mno, tak tohle je skutecne voda na mlyn anti-Cckaru :-). Musim se priznat,
ze i ja jsem na poprve tipoval spatne. Tusil jsem, ze -250 to nebude, ale
ten vysledek mne taky prekvapil :-).
  A nejhorsi na tom je, ze gcc ani s volbou -Wall nevyda pri kompilaci
vubec zadne varovani - je to prece v norme dano a tak je vse v poradku :-).
MSVC vyda nejaky warning ?

S pozdravem Pavel Troller

> Ono sa nielen ze strati znamienko, ono sa cislo sa bude chapat presne
> podla jeho reprezentacie, kym bolo este znamienkove. T.j. -50 sa pri
> 32-bit integeri zmeni  4294967246.
> 
> Teraz ma od nas po pive aj Lukas :-)
> 
> miro
> 
> 2009/3/5, Jan Waclawek <konfera@efton.sk>:
> > Kua, to akoze sa to znamienko strati?
> >
> > Mnojo, vidim, ze tych piv este bude... ;-)
> >
> > wek
> >
> > ----- Original Message ---------------
> >
> > >Uzasne! Toto by ma pri pisani programu nenapadlo...Vysvetlenie sa ale
> > >skryva v inom pravidle:
> > >
> > >Otherwise, if the operand that has unsigned integer type has rank greater or
> > >equal to the rank of the type of the other operand, then the operand with
> > >signed integer type is converted to the type of the operand with unsigned
> > >integer type.
> > >
> > >miro
> > >
> > >2009/3/5, Luká? Grepl <L.Grepl@sh.cvut.cz>:
> > >> > If an int can represent all values of the original type, the value is
> > >> > converted to an int;
> > >> > otherwise, it is converted to an unsigned int. These are called the integer
> > >> > promotions.48) All other types are unchanged by the integer promotions.
> > >>
> > >> Tohle to má ur?ité vtipné d?sledky. Zrovna p?ed pár dny jsem se s tím
> > >> p?kn? vypekl a to jsem si (naivka) myslel, ?e u? mi integral promotion
> > >> ned?lá problémy.
> > >>
> > >> Tak?e kdy? u? jsme u t?ch kvíz?, jakých hodnot m??e nabývat c?
> > >>
> > >>        int a = -50;
> > >>        unsigned int b = 50;
> > >>
> > >>        int c = a * b / 10;
> > >>
> > >> Luká? Grepl
> > >>
> > >> P.S. Integral promotion: It doesn't have to be logical. It's the law.
> >
> _______________________________________________
> HW-list mailing list  -  sponsored by www.HW.cz
> Hw-list@list.hw.cz
> http://list.hw.cz/mailman/listinfo/hw-list



Další informace o konferenci Hw-list