Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: Henryp on April 01, 2014, 03:31:54 PM
-
This ladder is converting a gallon per minute flow rate to million gallons per day.
I don't understand why my GPM value x 1440/1000000 yields a different answer than my GPM value X 0.00144.
-
Change the first MATH expression to ...
GPM value x 1440.0/1000000.0 (note the .0s)
With no floating point operands the first one is evaluated using integer math.
-
Computers have "optimized" integer math and then "floating point" math when needed.
So, 1/2 = 0 (integer divided by integer yields an integer, using TRUNCATION NOT ROUNDING)
2/3 = 0
9/10 = 0
10/10 = 1
Do-more will do everything in integer math UNTIL the expression uses a REAL, THEN ALL REMAINING CALCULATIONS use Floating Point.
So (1 + 4) / 2 = 2
(1 + 4) / 2.0 = 2.5
(1 + 4.0) / 2 = 2.5
TOREAL(1 + 4) / 2 = 2.5 (Do-more's TOREAL() function is usually used on D/V/.Acc integer registers, but can take any "expression" as its parameter)
RAD/DEG/SQRT functions always return a REAL result, regardless of whether its parameter expression type is integer or real. There might be a couple more that are that way. Can't remember off the top of my head. STDEVR/STDEVPR are 2 more.
-
Thanks