Opened 19 years ago

Last modified 18 years ago

#72 closed defect (fixed)

Function with for loop computes wrong value

Reported by: davbr Owned by: davbr
Priority: critical Milestone:
Component: Version:
Keywords: Cc: davbr, Adrian Pop

Description


Change History (1)

comment:1 by davbr, 19 years ago

function avg

input Real x[:];
output Real y;

algorithm

y := 0;
for i in x loop

y := y + i;

end for;
y := y / size(x,1);

end avg;

avg({1,2,3,4,8})

evaluates to 2.0, but it should be 3.6

Note: See TracTickets for help on using tickets.