Print the value of a function

Hi all¡¡ I have defined a very simple function that transfer fahrenheit to celsius and I want to introduce as a variable the Fharenheit and return Celsius. I would like to print the value of the Celsius but i cant undestand why i get 0 value…does someone knows where is the error? Thanks in advanced¡¡

float tempConverter(float F) {
float C=(F-32)*(5/9);
return C;
}

void draw() {
float t=tempConverter(500);
println(t);
}

Thank you¡

Hi,

Try with 32.0, 5.0 and 9.0

I think you need to be sure that all your values are float numbers. Without .0 they are consider as int and thus you have troubles with your divisions.

2 Likes

Thanks a lot @jb4x i was getting mad cause I didn’t find the error. Thanks

1 Like

With pleasure :slight_smile:

When you are not use to it, it can be very, very annoying !

1 Like