Skip to content

Commit 4e556ae

Browse files
committed
Document new TFraction.Hash method
1 parent c4d9243 commit 4e556ae

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

Fractions/0/API/TFraction-Hash.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Hash method
2+
3+
**Project:** [Fractions](../API.md)
4+
5+
**Unit:** _DelphiDabbler.Lib.Fractions_
6+
7+
**Record:** [_TFraction_](./TFraction.md)
8+
9+
**Applies to:** ~>0.2
10+
11+
```pascal
12+
function Hash: Integer;
13+
```
14+
15+
## Description
16+
17+
Computes and returns a hash value for the fraction as an _Integer_.
18+
19+
If two fractions that simplify to the same fraction have the same hash.
20+
21+
### Example
22+
23+
```pascal
24+
var
25+
F, G: TFraction;
26+
begin
27+
F := TFraction.Create(1, 2);
28+
G := TFraction.Create(3, 6);
29+
Assert(F.Hash = G.Hash);
30+
end;
31+
```

Fractions/0/API/TFraction.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ _TFraction_ defines several methods. Some are static class methods that operate
7979
| [_CompareTo_](./TFraction-CompareTo.md) | Compares the fraction to another and returns a value indicating which fraction is greatest or if they are equal. |
8080
| [_Convert_](./TFraction-Convert.md) | Converts the fraction into an equivalent one in which the numerator and denominator are a given integer multiple of their original values. |
8181
| [_HasCommonFactor_](./TFraction-HasCommonFactor.md) | Checks if a given integer is a common factor of the fraction. |
82+
| _[Hash](./TFraction-Hash.md) [~>0.2]_ | Computes a hash for the fraction. |
8283
| [_IsProper_](./TFraction-IsProper.md) | Checks if the fraction is a proper fraction. |
8384
| [_IsWholeNumber_](./TFraction-IsWholeNumber.md) | Checks if the fraction represents a whole number. |
8485
| _[Power](./TFraction-Power.md) [~>0.2]_ | Computes an integer power of a fraction (overloaded with class method). |

0 commit comments

Comments
 (0)