• Aucun résultat trouvé

31): lTemp: LongCARDINAL: IF den.highbits • 0 THEN BEGIN [quotient.highbits, qq

N/A
N/A
Protected

Academic year: 2022

Partager "31): lTemp: LongCARDINAL: IF den.highbits • 0 THEN BEGIN [quotient.highbits, qq"

Copied!
2
0
0

Texte intégral

(1)

Double.mesa 2-Sep-78 13:68:17

-- Double.Mesa Edited by Sandman on May 12, 1978 2:14 PM DIRECTORY

DoubleDefs: FROM "doubledefs" USING [DAdd, DCompare, DSub], InlineDefs: FROM "inlinedefs" USING [

BITSHIFT, LongCARDINAL, LongDiv, LongDivMod, LongMult], StringDefs: FROM "stringdefs" USING [AppendChar];

DEFINITIONS FROM InlineDefs, DoubleDefs;

Double: PROGRAM IMPORTS StringDefs EXPORTS DoubleDefs • PUBLIC BEGIN

DDivide: PROCEDURE [num, den: LongCARDINAL]

RETURNS [quotient, remainder: LongCARDINAL] • BEGIN

qq: CARDINAL:

count: [0 .. 31):

lTemp: LongCARDINAL:

IF den.highbits • 0 THEN BEGIN

[quotient.highbits, qq] ~

LongDivMod[[lowbits:num.highbits,highbits:O],den.lowbits]:

[quotient.lowbits, remainder.lowbits] ~

LongDivMod[[lowbits:num.lowbits,highbits:qq],den.lowbits]:

remainder.highbits ~ 0:

ELSE END BEGIN count ~ 0:

quotient.highbits ~ 0:

Hemp ~ den:

WHILE lTemp.highbits # 0 DO -- normalize Hemp. lowbits ~

BITSHIFT[lTemp.lowbits,-1] + BITSHIFT[1Temp.highbits,16]:

lTemp.highbits ~ BITSHIFT[1Temp.highbits,-1]:

count ~ count + 1: . ENDLOOP;

qq ~ LongDiv[num,lTemp.lowbits]; -- trial quotient qq ~ BITSHIFT[qq,-count];

lTemp ~ LongMult[den.lowbits,qq]; -- multiply by trial quotient lTemp.highbits ~ lTemp.highbits + den.highbits*qq;

UNTIL DCompare[1Temp, num] # greater DO

-- decrease quotient until product is small enough lTemp ~ DSub[1Temp,den];

qq ~ qq - 1;

ENDLOOP;

quotient.lowbits ~ qq;

remainder ~ DSub[num,lTemp];

END;

RETURN END;

DMultiply: PROCEDURE [a,b: LongCARDINAL]

RETURNS [product: LongCARDINAL] • BEGIN

product ~ LongMult[a.lowbits, b.lowbits]:

product.highbits ~

product.highbits + a.lowbits*b.highbits + a.highbits*b.lowbits;

RETURN END;

DNeg: PROCEDURE [a: LongCARDINAL] RETURNS [LongCARDINAL] • BEGIN

RETURN[DSub[[O,O],a]]:

END:

DInc: PROCEDURE [a: LongCARDINAL] RETURNS [LongCARDINAL] • BEGIN

RETURN[DAdd[[l,O],a]]

END:

AppendDouble: PROCEDURE [s: STRING, a: LongCARDINAL] • BEGIN OPEN StringOefs;

10ngZero: longCARDINAl • [highbits:O. lowbits:O];

long10: LongCARDINAL • [highbits:O. lowbits:l0]:

Page 1

(2)

Double.mesa 2-Sep-78 13:58:17

xn: PROCEDURE ..

BEGIN

charZero: CARDINAL" LOOPHOLE['O];

r: LongCARDINAL;

IF a # longZero THEN BEGIN

[a, r] ~ DDivide[a, 10ng10];

xn[];

AppendChar[s, LOOPHOLE[r.lowbits+charZero. CHARACTER]];

END;

END;

IF a .. longZero THEN AppendChar[s. '0] ELSE xn[];

RETURN

END; --AppendDouble END ...

Page 2

Références

Documents relatifs

[r]

[r]

School of Mathematics and Statistics, Southwest University, Chongqing, 400715, People’s Republic of China – and – School of Mathematical Science, Kaili University, Kaili,

We must admit that the observing and knowing subject (the model builder), as any human being, has a project, usually complex, aggregating multiple and evolutionary goals, and that

Elle peut prendre un argument numérique indiquant le nombre de boucles à sauter, dans le cadre de boucles imbriquées (rapidement illisible). Elle peut prendre un argument

[r]

Quelques concepts de base Premiers pas avec Caml Le branchement conditionnel

initialisation (par lecture) des variables d'entrée ; writeln est facultatif, readln indispensable. pas de point virgule avant