Android Question Values are different and not sure why

patrick14384

Member
Licensed User
Longtime User
Attached is a sample program showing the issue I am facing. The suspect code is
B4X:
    CurrentTemperature = Temperature_Live.Get(Temperature_Live.Size -1)
    PreviousTemperature = Temperature_Live.Get(Temperature_Live.Size -2)
     
    'Shouldn't these values be the same?  I do not understand why these values would be different
    DiffTemperature1 = CurrentTemperature - PreviousTemperature
    Log("First number: " & DiffTemperature1)
    DiffTemperature2 = Temperature_Live.Get(Temperature_Live.Size -1) - Temperature_Live.Get(Temperature_Live.Size -2)
    Log("Second number: " & DiffTemperature2)

DiffTemperature1 I would think would equal DiffTemperature2, but instead DiffTemperature1 equals 1.666 and DiffTemperature2 equals 2.0.

Can someone explain to me what I am doing wrong? Attached is the source, put a break at line#95 to see the issue. I am using B4A v4.0 if that matters at all.

Thanks very much!
Patrick
 

Attachments

  • B4AIssue.zip
    483.6 KB · Views: 150
Last edited:
Top