2 questions (big numbers + HD vs DD)

Giorgos Keramidas keramida at ceid.upatras.gr
Wed Nov 17 09:36:33 EET 1999


Mike <ps40 at ukc.ac.uk> writes:

> On Tue, 16 Nov 1999 14:47:07 +0200 (EET) Michalis Kabrianis 
> <kabrianis at hellug.gr> wrote:
> # Kamia glwssa den xeirizetai megalyterous apo oti mia alli 
> # xamiloterou epipedou
> # *praktika*. An skefteis as poume oti i perl einai grammeni se C, tha katalabeis
> # oti kanei ena trick gia na ftasei se megalytera noumera to opoio tha mporouses
> 
> otan les trick ennoeis "kobei" ton ari8mo kai kanei 
> prakseis me mikroterous 'i kati tetoio telwspantwn?!?!

Diaforoi tropoi uparxouv.  Gia paradeigma av se mia arxitektovikn to
word-size eivai 32-bit, mporeis na theoriseis pos to `unsigned long'
exei to maximum word size otan grafeis se C, opote mporeis na
antiproswpeuseis arketa megalous arithmous mesa se data structures opws
to parakatw:

	struct big_num {
		int flags;		/* sign, oveflow, ktl. */
		unsigned long data;
		unsigned long len;	/* megethos tou data[] */
	};

An kai se glwsses opws h LISP apo oti thymamai den xreiazetai na kaneis
esy tipota gia na xrhsimopoihseis bignums, alla akoma kai apla kommatia
kwdika opws to:

	(defun fact (n)
	  (cond ((< n 0) 0)
		((< n 2) 1)
		(else (* n (fact (- n 1))))))

kanoun xrhsh twv bignums, opote mporeis aneta na breis to (fact 1000)
xwris polles polles fasaries.

> # pragma apolyta apodekto). Telos, oles oi glwsses milane assembly
> # kata bathos, ara exoun akribws tous idious periorismous se toso apla
> # themata (diladi xrisi arithmwn) kai to mono pou tous leipei (i tous
> # perissevei, opws to deis) einai mia routina xeirismou.
>  
> Dhladh gia paradeigma i C bazei ton periorismo na 
> ka8oriseis ton ari8mo pou 8a dextei gia poion logw? Gia 
> stability kai security??

Giati stin C ta integer data types pou orizei to protypo tis glossas
einai ayta akribos pou fantazesai.  Dnladn: char, short, int, kai long,
me signed kai unsigned parallages tous.

Oti periorismous exei to hardware, oson afora toys arithmous pou mporei
na anaparastnsei me to polu ena plhres word, aytous exei kai h C.  Den
eimai sigouros oti katalaba poia akribws einai h aporia sou.

> Estw mia glwssa pou _den_ sou apaitei na ka8oriseis ton ari8mo pou 8a
> dex8ei. Tote ayth 8a mporei na kanei ypologismous oso thn epitrepei i
> glwssa (assembly) pou grafthke????

Aytovonto.  H apodeiksi afinetai san askisi ston anagnosti.

-- 
Giorgos Keramidas, <keramida at ceid.upatras.gr>
"What we have to learn to do, we learn by doing." [Aristotle]
--
====================================================================
Gia boithia (h na diagrafhte) e-mail sto majordomo at hellug.gr
Ta archives tis listas einai sto http://lists.hellug.gr/archives
prin steilete kapoia erothsh psakte mipos exei hdh apanththei.
Gia opoiodipote problima stilte e-mail ston owner-linux-greek-users at hellug.gr
====================================================================



More information about the Linux-greek-users mailing list