lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


2013/8/13 KHMan <keinhong@gmail.com>

I don't see any comparison anywhere... Where does the equality comparison fit in?


Here is the code, extracted and simplified from my test case.
This is the case when measuring apparatus gives a normalized value.

--
-- input vales
--
O2 = 12.95
H2O = 100 - (100 / 1.2)
T = 136.575
P = 1013.25 / 1.25
--
O2_r = 10.95
H2O_r = 0
T_r = 273.15
P_r = 1013.25
--
SO2_in = 5.3333333333333
--

--
-- calculations
--

-- correction factor
O2_cf = (20.95 - O2_r) / (20.95 - O2)
H2O_cf = (100 - H2O_r) / (100 - H2O)
T_cf = (T + T_r) / T_r
P_cf = P_r / P
--
print (
  O2_cf, O2_cf == 1.25, 
  H2O_cf, H2O_cf == 1.2, 
  T_cf, T_cf == 1.5, 
  P_cf, P_cf == 1.25
)

-- normalized value
SO2 = SO2_in * (O2_cf * H2O_cf * T_cf * P_cf)
print (
  SO2, SO2_in * (O2_cf * H2O_cf * T_cf * P_cf), 
  SO2 == SO2_in * (O2_cf * H2O_cf * T_cf * P_cf)
)

-- inverse operation: from normalized value calculating measured value
-- !!!
print (
  SO2_in, 15 / (1.25 * 1.2 * 1.5 * 1.25),
  SO2_in == 15 / (1.25 * 1.2 * 1.5 * 1.25)
)
assert (SO2_in == 15 / (1.25 * 1.2 * 1.5 * 1.25))


2013/8/13 KHMan <keinhong@gmail.com>

So, assuming you now know about floating point, do you still require an equality comparison?


Yes, I think this is the best way to test.