What does this line of code mean?

后端 未结 7 1019
抹茶落季
抹茶落季 2021-01-21 04:39

I am wondering what this line of code mean?

b = (gen_rand_uniform()>0.5)?1:0;

The gren_rand_uniform() is a function to generate

相关标签:
7条回答
  • 2021-01-21 05:23

    Conditional assignment:

    variable = condition ? value_if_true : value_if_false;
    

    which is equal to:

    if (condition) {
        variable = value_if_true;
    } else {
        variable = value_if_false;
    }
    

    The code you give us is just random bool. It will return either 1 or 0.

    0 讨论(0)
提交回复
热议问题