Hi
Please can someone help me to translate this ternary operation:
return ( ( ayr[7] >> ch | tons >> ch ) & ( ayr[7] >> ch+3 | noiv ) & 1 ) * amp[ ayr[8+ch] & 0x10 ? envv : ayr[8+ch] & 0x0f ];
in to IF and ELSE statement?
Thank's.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hi
Please can someone help me to translate this ternary operation:
return ( ( ayr[7] >> ch | tons >> ch ) & ( ayr[7] >> ch+3 | noiv ) & 1 ) * amp[ ayr[8+ch] & 0x10 ? envv : ayr[8+ch] & 0x0f ];
in to IF and ELSE statement?
Thank's.
Put what is before the ? into the if condition
put what is between the ? and the : in the true part
put what is after the : into the else part
each section will return its value.
If you don't understand my answer, don't ignore it, ask a question.
Normally i do this.
But in this case, the blacket opened after amp is closed after : , at the end of expression
That confused me...
I didn't try to compile the code to see if it had syntax errors. Does the posted code compile ok?
If you don't understand my answer, don't ignore it, ask a question.
Sorry i can not compile because i'm translating the source to another language (Purebasic).
This is the complete function:
function cstep(ch) { if( ++ayr[ch+16] >= (ayr[ch<<1] | ayr[1|ch<<1]<<8) ) ayr[ch+16]= 0, tons^= 1 << ch; return ( ( ayr[7] >> ch | tons >> ch ) & ( ayr[7] >> ch+3 | noiv ) & 1 ) * amp[ ayr[8+ch] & 0x10 ? envv : ayr[8+ch] & 0x0f ];
That must be javascript. function is not a keyword in java.
If you don't understand my answer, don't ignore it, ask a question.
Ah...ok.
Thank you.
if (ayr[8+ch] & 0x10) return ((ayr[7] >> ch | tons >> ch) & (ayr[7] >> ch+3 | noiv) & 1) * amp[envv]; else return ((ayr[7] >> ch | tons >> ch) & (ayr[7] >> ch+3 | noiv) & 1) * amp[ayr[8+ch] & 0x0f ];
Thank you!