This question already has an answer here:
- What does ? in C mean? 8 answers
On Maxeler machines I am not allowed to use if-else statement so instead, I can only use: condition ? first_expression : second_expression;
On this following code piece, if my condition is false, does the code first run first_expression and than run second_expression. Or does it only run second_expression?
[Q]If it runs first_statement and then second_statement, how can I for code to run only second_statement?
//condition ? first_expression : second_expression;
out[m] = withinBounds?sum[m]: (<condition>) ?
stream.offset(in[m], 0) : calculate_sum() ;
If I ask this question in a larger picture: If condition_1 is false, does it only run calculate_sum(input_2)
, without running:
(<condition_2>) ? stream.offset(in[m], 0) :
calculate_sum(input)
Second example:
out[m] = withinBounds?sum[m]:
(<condition_1>) ?
(<condition_2>) ? stream.offset(in[m], 0) :
calculate_sum(input)
:calculate_sum(input_2);
Aucun commentaire:
Enregistrer un commentaire