Question: Trying to convert some code, but for all my googling I can't figure out how to convert this bit.

```
    float fR = fHatRandom(fRadius);
    float fQ = fLineRandom(fAngularSpread ) * (rand()&1 ? 1.0 : -1.0);
    float fK = 1;

```

This bit

```
(rand()&1 ? 1.0 : -1.0); 

```

I can't figure out.

Answer: 
The C++ sample generates a random number, uses its lowest bit and throws away the rest. The lowest bit is then used to pick either -1 or 1.

In C#, the equivalent is as follows.

```
new Random().Next(0, 2) * 2 - 1

```

**Important**: If you do this in a loop, store the instance of `Random` somewhere and only call `Next` in the loop, not the constructor again. This is not only a performance optimization. You would otherwise see sequences of identical bits of duration of approximately 100 ms, so calls to the parameterless constructor of Random should be few and far between, ideally one per your app's startup.
You can just randomize with 50% chance, as others said.

If you want an exact translation, it would be: 

```
((new Random().Next() & 1 > 0) ? 1.0 : -1.0)

```

You have to make a boolean out of the first part of conditional expression.