/ Datendarstellung & Speicher
Speicherbedarf Float
Speicherbedarf für eine Folge Gleitkommazahlen: Speicher = Anzahl · ByteProFloat. 4 Byte für float32, 8 Byte für float64 (double).
01 · Eingabe
Speicherbedarf Float berechnen
Speicherbedarf für eine Folge Gleitkommazahlen: Speicher = Anzahl · ByteProFloat. 4 Byte für float32, 8 Byte für float64 (double).
Lösen für
- Speicher — Speicherbedarf
- Anzahl — Anzahl Werte
- ByteProFloat — Byte pro Float
Speicher = Anzahl · ByteProFloat
Anzahl = Speicher / ByteProFloat
ByteProFloat = Speicher / Anzahl
Byte
Byte
Worum geht es?
Gleitkommazahlen nach IEEE 754 haben festgelegte Bitbreiten:
- float32 (single): 4 Byte — 1 Vorzeichen, 8 Exponent, 23 Mantisse
- float64 (double): 8 Byte — 1 Vorzeichen, 11 Exponent, 52 Mantisse
- float16 (half): 2 Byte — Maschinelles Lernen, GPU
- float128 (quad): 16 Byte — Wissenschaftliches Rechnen
Der Speicherbedarf einer Folge skaliert linear: Speicher = Anzahl · ByteProFloat.
Die Formel
Speicher = Anzahl · ByteProFloat
Umstellungen:
Anzahl = Speicher / ByteProFloat
ByteProFloat = Speicher / AnzahlDie Variablen
| Symbol | Bedeutung | Einheit | Erklärung |
|---|---|---|---|
| Anzahl | Anzahl Werte | — | Anzahl der Float-Werte. |
| ByteProFloat | Byte pro Float | Byte | Bytes pro Wert (4 oder 8). |
| Speicher | Speicherbedarf | Byte | Gesamter Speicherbedarf. |
Minimal-Beispiel
1024 float64-Werte:
Speicher = 1024 · 8
= 8192 Byte
= 8 KiBPraxis-Beispiele
Beispiel 1 — Audio-Sample-Buffer
48.000 float32-Samples (1 s bei 48 kHz mono):
Speicher = 48.000 · 4
= 192.000 Byte
≈ 187,5 KiBBeispiel 2 — Numerisches Gitter
Ein 2D-Gitter 1024 × 1024 als float64-Matrix:
Speicher = 1024 · 1024 · 8
= 8.388.608 Byte
= 8 MiBBeispiel 3 — Speicher → Anzahl
Wie viele float32-Werte passen in 1 MiB?
Anzahl = 1.048.576 / 4
= 262.144 Werte