Invalid operands of type 'double' and 'int' to binary 'operator%' error

I am new to the c++ language and I am not use to having to assign operand types to variables. I have written some simple code to read temperatures from a thermistor and I am getting the following error:

Thermistor_code.ino: In function 'void loop()':
Thermistor_code:24: error: invalid operands of types 'double' and 'int' to binary 'operator^'

here is my code:

//thermistor temperature reading
int R_o = 10000;    //resistance of thermistor at 0 degrees celcius
int T_o = 273;     //Kelvin - equal to 0 deg celc
int R_b = 10000;   // ballast resistor
int V_in = 5;      // input voltage to voltage divider circuit
int R_th = 0;      //sets an initial value for thermistor resistance
int Beta = 3753.8; //calculated value from callibration
int T_therm = 0;   
int T_therm_fah = 0;
void setup() {
  // starts serial communication at 9600 bits per second:
  Serial.begin(9600);
}


void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float V_o = sensorValue * (5.0 / 1023.0);
  V_o = 5-V_o;
//routine runs once you press reset:
   R_th = R_b/((V_in/V_o)-1);  //calculates instantaneous resistance of the thermistor based on voltage
   T_therm = (log(R_th/R_o)/Beta+1/T_o)^(-1)-273;
   T_therm_fah = T_therm*1.8+32;
  Serial.println(T_therm_fah); //prints temp to serial monitor in degrees Fahrenheit
  //Serial.println(R_th); //prints R_th to serial monitor
  //Serial.println(T_therm); //prints temp to serial monitor in degrees celcius
  //Serial.println(V_o);  //prints output voltage from voltage divider circuit

If anyone could kindly point out what I have done wrong I would appreciate it. I know that is has to do with the operand types I have assigned to the variables, but I have played around with some things and was not able to fix the issue.

Here, the symbol ^ does not mean exponentiation but something different entirely. (This is a gotcha for those used to other programming languages.)
Besides, you don't need to use -1 as an exponent. You can rewrite the formula to use division instead.

odometer:
Here, the symbol ^ does not mean exponentiation but something different entirely. (This is a gotcha for those used to other programming languages.)
Besides, you don't need to use -1 as an exponent. You can rewrite the formula to use division instead.

Just to expand on this, the ^ operator is the bitwise exclusive OR operator, which is only defined for integer classes (| is the bitwise inclusive OR operator, & is the bitwise AND operator, and ~ is the bitwise NOT operator) . There is no exponention operator in C++, but you can use the pow function. As odometer says, for the special case of -1, just use division.

aha! Thanks for the help. Yeah, the equations I used came from a previous program I wrote in a different language where it was just as easy to inverse the eq. using the "^-1". I will go ahead and just divide here like you both have suggested. Good to know that about c++ now.

Thanks!!

MichaelMeissner:
^ is the bitwise inclusive OR operator,

I think you meant | (vertical stroke) is the inclusive OR operator.
The new forum sucks for programmers. Thirty-three smilies.

hey so I fixed the first issue and now I have run into a problem that I cannot seem to explain. Here is my code below. Please excuse its messiness. Unnecessary things have been added to make “tests” and other things have been commented out for troubleshooting purposes. The final code will be cleaned up.

//thermistor temperature reading
int R_o = 10000;    //resistance of thermistor at 0 degrees celcius
int T_o = 273;     //Kelvin - equal to 0 deg celc
int R_b = 10000;   // ballast resistor
int V_in = 5;      // input voltage to voltage divider circuit
float Beta = 3753.8; //calculated value from callibration

void setup() {
  // starts serial communication at 9600 bits per second:
  Serial.begin(9600);
}


void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float V_o = sensorValue * (5.0 / 1023.0);
  V_o = 5-V_o;
// the setup routine runs once when you press reset:
  float R_th = R_b/((V_in/V_o)-1);  //calculates instantaneous resistance of the thermistor based on voltage
  float x = log(R_th/R_o);
  float T_therm = (1/(x/Beta+(1/T_o)))-273;
  float T_therm_fah = T_therm*1.8+32;
   delay (250);
  //Serial.println(T_therm_fah); //prints temp to serial monitor in degrees fahrenheit
  Serial.println(R_th); //prints R_th to serial monitor
  Serial.println(T_therm); //prints temp to serial monitor in degrees celcius
  //Serial.println(V_o);  //prints output voltage from voltage divider circuit
  Serial.println(x);

I am having trouble with my T_therm calculation. All of the other numbers are correct and my circuit is set up properly. I can calculate the temp using my calculator and I am able to get a reasonable 67-68 deg Fahrenheit for my room temp reading based on my R_th from the code. Here is what my serial monitor is displaying however:

Serial mon.
4013.70 R_th reading
-4385.08 T_therm <<<this is the number that is incorrect. For room temp it should be about 19-20 deg celcius
-0.91 This is just the log(R_th/R_o) which is being calculated proper (only here for my testing purposes)

So I know that all the numbers up until I try and calculate T_therm are working, reasonable, and accurate to actual temperatures.

Because (1/T_o) gives you maybe zero.
Try:

..(1.0/(x/Beta+(1.0/(float)T_o)))-273.0;

When you rewrite the code from other language mind the casting in C. It is good to indicate you do calcs with float.

odometer:

MichaelMeissner:
^ is the bitwise inclusive OR operator,

I think you meant | (vertical stroke) is the inclusive OR operator.
The new forum sucks for programmers. Thirty-three smilies.

Thanks, fixed.

Thanks Pito. That did the trick. Calculating good temps now.