Convert Fahrenheit to Celcius?

Noel

Member
Licensed User
Longtime User
I am trying to convet Fahrenheit to Celcius.

The formula to do so is: C = (F - 32) / 1.8 (where F is the Fahrenheit value)

For some reason does
B4X:
Celcius = (30 - 32) / 1.8
give me -1, but when doing the calculation on a calculator is shows -1.11111

I need the -1.11111 value. How can I get this done in "basic"?

Same with
B4X:
Celcius = (22 - 32) / 1.8
In basic it returns -5
When doing the maths on a calculator it gives me -5.55....
 
Last edited:

Mahares

Expert
Licensed User
Longtime User
You need to declare the variables as double:
B4X:
Dim F As Double=30
Dim C As Double
C=(F-32)/1.8
Msgbox (C,"")  'returns -1.11111
 
Upvote 0
Top