Posted by Fox on 2000-09-05
Yeah, Sharvil, that one makes more sence. Thanks for correcting me, I don't
have much experience with the tertiary operator as it make the code (for me at
lesat) confusing. I preferr to use if/else blocks all the time to keep everything
consistant. The ?: operator is just too confusing to me, which is why I aviod it at
all costs!!
Although, I don't understand what the '&' operator does as a logic test. Same
with the '|'.
/****************************/
On 6 Sep 2000, at 4:27, Sharvil Nanavati wrote:
> > This is the tertiary operator, and is simply a more compact way of
> > writing if/else
> > statements. Its form is:
> >
> > conditional statement ? true condition -body of the "if" block- :
> > false condition -
> > body of the "else" block-
>
> Couldn't have put it better myself! :)
>
> > to rewrite this line:
> >
> > #define SIN
> > (negate?((_inp(base+1)&snes_din)?1:0):((_inp(base+1)&snes_din)?0:1))
> >
> > as if/else statements:
> >
> > if(_inp(base+1) & snes_din)
> > {
> > negate = 1;
> >
> > #define SIN 0
> > }
> > else
> > {
> > negate = 0;
> >
> > #define SIN 1
> > }
>
> I don't know about that... I think it translates to a different set of
> if/else:
>
> if(negate)
> {
> if(_inp(base + 1) & snes_din)
> SIN = 1;
> else
> SIN = 0;
> }
> else
> {
> if(_inp(base + 1) & snes_din)
> SIN = 0;
> else
> SIN = 1;
> }
>
> Now, SIN isn't actually a variable - although the define makes it act
> like one. I think this is how it should be, but please do correct me if
> I'm wrong. Hope this helps.
>
> Cheers,
> Sharvil Nanavati
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Mail - Free email you can access from anywhere!
> http://mail.yahoo.com/
> >
>
Previous post | Next post | Timeline | Home