|
I'm confused with how the precision works in RPG right now? I'm creating
a program to convert Miles Per Gallon, to Litres Per 100 Km, for my own
personal use. Anyway, I can code the calculation two different ways, one
truncates the other does not. Using the temp field in each step works
great, exactly what I want, but if I try to do it all in one calculation I
get truncation. What gives? Here's the definitions and code.
?*-Define constant
fields--------------------------------------------------------
d Conv_To_Km c Const(0.621371192237334)
d Conv_To_Litres c Const(3.78623545651745)
?*-Define stand alone
fields-----------------------------------------------------
D Temp S 15 5
D Ltrkm S 10 2
...
?* Calc the litres per 100 km based off the mpg
c Eval Temp = Mpg / Conv_To_Litres
c Eval Temp = Temp / Conv_To_Km
c Eval Ltrkm = 100 / Temp
This works great, but next line (which is pretty much the whole thing in
one) is giving me fits.
c Eval Temp =
100/((Mpg/Conv_To_Litres)/Conv_To_Km)
RNF7551: Result of numeric operation is truncated to 0 decimal places.
Ron Power
Programmer
Information Services
City Of St. John's, NL
P.O. Box 908
St. John's, NL
A1C 5M2
Tel: 709-576-8132
Email: rpower@xxxxxxxxxx
Website: http://www.stjohns.ca/
___________________________________________________________________________
Success is going from failure to failure without a loss of enthusiasm. -
Sir Winston Churchill
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.