This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

entier is the integer value (2)

numerateur is the numerator (1)

Denominateur is the denominator (2)

the result is the rest (0)

so the fraction is 2 + 1/2

to test if the value is a fraction, test if the rest is 0. If not, the return values is the nearest fraction (2.511 -> 2 + 93/182 + 1.1e-5)

Function Fraction(Value:double; Var Entier, Numerateur, Denominateur:LongInt):Doub

Const

MaxFrac=256; //max value of the denominator

EqZero=1E-10;

Var

Actuel:Double;

i:Integer;

Begin

entier:=Trunc(Value);

Value:=Frac(Value);

Result:=Value;

For i:=2 To MaxFrac Do

Begin

Numerateur:=Trunc(Value * i + EqZero);

Actuel:=Value - Numerateur / i;

If Abs(Result)>Abs(Actuel) Then

Begin

Denominateur:=i;

Result:=Actuel;

If Actuel<EqZero Then

Begin

Result:=0;

Break;

End;

End;

End;

Numerateur:=Trunc(Value * Denominateur + EqZero);

End; {Fraction}