View Issue Details

IDProjectCategoryView StatusLast Update
0002057JEDI VCL00 JVCL Componentspublic2004-08-18 00:20
ReporterrokoAssigned Touser72 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0002057: IntPower: wrong result (JvJCLUtils.pas)
DescriptionIntPower function is returning Base value as result when Exponent = 0, which is wrong, as result must be equal 1.

Also 1 div Base (Base is integer) equals 0 for every non-zero value of Base, so evaluating result for negative Exponent is pointless, may as well return 0 immediately.
Additional InformationResulting function code:

function IntPower(Base, Exponent: Integer): Integer;
begin
  if Exponent > 0 then
  begin
    Result := Base;
    Dec(Exponent);
    while Exponent > 0 do
    begin
      Result := Result * Base;
      Dec(Exponent);
    end;
  end
  else
    if Exponent < 0 then
      Result := 0;
    else
      Result := 1;
end;
TagsNo tags attached.

Activities

user72

2004-08-18 00:20

  ~0005015

Just to be sure, I compared to the results of Math.IntPower and it matches.
Fixed in CVS

Issue History

Date Modified Username Field Change
2004-08-16 06:31 roko New Issue
2004-08-18 00:20 user72 Status new => resolved
2004-08-18 00:20 user72 Resolution open => fixed
2004-08-18 00:20 user72 Assigned To => user72
2004-08-18 00:20 user72 Note Added: 0005015