Martik - 4 months ago 55

C++ Question

I am trying to do a math function in a function-block in NodeRed(c++) but it can only handle easier task like multiply.

I am trying to do this function but it can't handle the exponents(^). Perhaps there is a math function or something to declare this? It just returns a wacko number as it is now.

`msg.payload = (6*10^47)/(msg.payload^16.66);`

return msg;

Answer

The `^`

operator doesn't do what you think it does, it's the bitwise XOR operator.

If you want to raise something to the power of x use `pow`

:

```
#include <cmath>
std::pow(msg.payload, 16.66);
```