Posted by Sharvil Nanavati on 2000-09-05
> 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