Price fraction: Difference between revisions

Content added Content deleted
mNo edit summary
(Rename variable)
Line 2,234: Line 2,234:
const func float: computePrice (in float: x) is func
const func float: computePrice (in float: x) is func
result
result
var float: result is 0.0;
var float: price is 0.0;
begin
begin
if x >= 0.0 and x < 0.06 then
if x >= 0.0 and x < 0.06 then
result := 0.10;
price := 0.10;
elsif x < 0.11 then
elsif x < 0.11 then
result := 0.18;
price := 0.18;
elsif x < 0.36 then
elsif x < 0.36 then
result := flt(((trunc(x * 100.0) - 11) div 5) * 6 + 26) / 100.0;
price := flt(((trunc(x * 100.0) - 11) div 5) * 6 + 26) / 100.0;
elsif x < 0.96 then
elsif x < 0.96 then
result := flt(((trunc(x * 100.0) - 31) div 5) * 4 + 50) / 100.0;
price := flt(((trunc(x * 100.0) - 31) div 5) * 4 + 50) / 100.0;
else
else
result := 1.0;
price := 1.0;
end if;
end if;
end func;
end func;
Line 2,267: Line 2,267:
const func float: computePrice (in float: x) is func
const func float: computePrice (in float: x) is func
result
result
var float: result is 0.0;
var float: price is 0.0;
local
local
var integer: index is 1;
var integer: index is 1;
Line 2,275: Line 2,275:
incr(index);
incr(index);
end while;
end while;
result := table[index][2];
price := table[index][2];
else
else
raise RANGE_ERROR;
raise RANGE_ERROR;