```C++
float_X x=position_x-L_x;
return float_X( math::abs(x)<=float_X(0.5) * L_x);
```
Your equation has defined ```x``` thus please also define it in your code, it is better to read.
Cast only the value ```0.5``` else first operation is 64bit and than down casted.