Welcome to the new DelphiDabbler Code Library Documentation.

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.

NotEqual operator overload

Project: Fractions

Unit: DelphiDabbler.Lib.Fractions

Record: TFraction

Applies to: ~>0.1

class operator NotEqual(const A, B: TFraction): Boolean;


This operator overload permits TFractions to be tested for inequality using the <> operator.

Two fractions are considered not equal unless they can be simplified to the same fraction. Formally, two fractions are unequal if their 1st and 2nd cross products are different. Take for example 3/4 and 7/8. Their 1st cross product is 3 × 8 = 24 and their 2nd cross product is 4 × 7 = 28. Since 24 <> 28, the fractions are not equal.

A TFraction can also be compared to integer and floating point types using the <> operator. The Implicit operator takes care of converting the integer and floating point operands to TFraction before performing the comparison.


  F1, F2: TFraction;
  D: Double;
  I: Integer;
  F1 := TFraction.Create(3, 4);
  F2 := TFraction.Create(3, 8);
  D := 0.25;
  I := 3;
  Assert(F1 <> F2);
  Assert(F2 <> F1);
  Assert(D <> F2);
  Assert(F1 <> D);
  Assert(I <> F2);
  Assert(F1 <> I);

See Also