This is a new site that's currently running on alpha code. There are going to be bugs. If you discover any, please report them on the site's issues page (GitHub account required). Thanks.

**Warning:** Many URLs *are* going to change. Refer to the README file to discover which library project's documentation has been completed.

**Project:** Fractions

**Unit:** *DelphiDabbler.Lib.Fractions*

**Record:** *TFraction*

**Applies to:** ~>0.1

```
class function Power(const F: TFraction; Exponent: ShortInt): TFraction; static;
```

Returns the given fraction *F* raised to the power of integer *Exponent*.

*Exponent* can be positive, zero or negative. When *Exponent* is negative the reciprocal of *F* is raised to the power of the absolute value of *Exponent*. This is because, for any number `n`

, `n^-x = 1/(N^x)`

.

If *F* is zero, *Exponent* must be non-negative.

The resulting fraction is simplified.

Here’s a simple function that squares the given fraction.

```
function Square(const F: TFraction): TFraction;
begin
Result := TFraction.Power(F, 2);
end;
```

And here is some code that write out all the integer powers of 1/2 from -32 to +32:

```
var
F, G: TFraction;
N: ShortInt;
begin
F := TFraction.Create(1, 2); // 1/2
for N := -32 to 32 do
begin
G := TFraction.Power(F, N);
WriteLn(
Format(
'1/2^%d = %d/%d', [N, G.Numerator, G.Denominator]
)
);
end;
end;
```

*Multiply*operator overload*Reciprocal*method