Autor Beitrag
JayK
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1013



BeitragVerfasst: Do 16.06.05 16:58 
Hallo,

bin ich hier in der richtigen Sparte?
Ich würde gerne wissen, ob, und wenn ja wo, es hier oder wo anders eine Übersicht oder Tabelle mit dem Speicherverbrauch von den verschiedenen Datentypen gibt.
Boolean belegt z.B. 1 Byte, das weiß ich (na ja, wahrscheinlich theoretisch nur 1 Bit, aber der Arbeitsspeicher benutzt ja glaub ich Byte als kleinstes) und String belegt einen variablen Platz, der von der String-Länge abhängt.
Über die Suche der DF und über die der Delphi-Hilfe hab ich nichts passendes gefunden.

Schonmal Danke im voraus,
JayK


Zuletzt bearbeitet von JayK am Fr 17.06.05 19:41, insgesamt 2-mal bearbeitet
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Do 16.06.05 20:14 
Hi JayK!
Schreib Dir doch ein kleines Programm, das mit Dir mit sizeof(Typ) die Größe der einzelenen Datentypen ausgibt. Nebenbei steht das irgendwo in der Hilfe, ich finde aber, es macht mehr Spass, es selbst rauszufinden.

Du kannst übrigens einen Boolean auch als 1bit abspeichern. Dann brauchst Du noch 7 weitere Boolean Werte, um das Byte aufzufüllen. Das geht mit einem packed array. Daneben gibt es auch noch einen packed record. Allerdings ist der Zugriff auf solche gepackten Strukturen langsam (Bei 3Ghz Büchsen aber auch egal)
Spaceguide
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 552


(D3/D7/D8) Prof.
BeitragVerfasst: Do 16.06.05 21:54 
Also ein packed array [0..7] of boolean frisst trotzdem 8 Byte.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Do 16.06.05 22:14 
Packed hat was mit dem Alignment zu tun, nicht mit der Bit-Belegung. Das wären sog. Unions und die kann Delphi nicht.

Was Du meinst sind sogenannte Sets und die kann Delphi ohne Probleme.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Do 16.06.05 22:23 
Hupsa, da ist Delphi nicht (mehr) Pascal-konform.
Was zeigt uns das?
Hör nicht auf Andere :oops:
@BenBE: In Turbo-Pascal war die Welt noch in Ordnung. Denn Pascal an sich kann Unions sehr wohl.
Kurz gegoogelt:
www.lernnetz-sh.de/k...l-Kurs/pas6pack.html
JayK Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1013



BeitragVerfasst: Fr 17.06.05 19:28 
OK hab ich gemacht (Prog geschrieben und geguckt):

(gehen hier gar keine Tabellen) :motz: (dafür könnte man hier HTML gebrauchen, aber das ist ja aus) :roll:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
Datentyp             Speicherbedarf                   Wertebereich
-------------------------------------------------------------------------------
Integer = LongInt:   4 Bytes                          -2^32/2 ... 2^32/2 - 1
ShortInt:            1 Byte                           -128 ... 127
SmallInt:            2 Bytes                          -32768 ... 32767
Int64:               8 Bytes                          -2^63 ... 2^63 - 1
-------------------------------------------------------------------------------
Cardinal = LongWord: 4 Bytes                          0 ... 2^32
Byte:                1 Byte (wer hätte es gedacht...) 0 ... 255
Word:                2 Bytes                          0 ... 65535
-------------------------------------------------------------------------------
Single:              4 Bytes                          1,5 * 10^-45 ... 3,4 * 10^38
Double = Real:       8 Bytes                          5 * 10^-324 ... 1,7 * 10^308
Extended:            10 Bytes                         3,6 * 10^-4951 ... 1,1 * 10^4932

[meta]Speicherbedarf Zahlen-Typen[/meta]
Jetzt gibts eine "Tabelle"