/ Datendarstellung & Speicher

Speicherbedarf Float

Speicherbedarf für eine Folge Gleitkommazahlen: Speicher = Anzahl · ByteProFloat. 4 Byte für float32, 8 Byte für float64 (double).

Speicherbedarf Float
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 = Anzahl · ByteProFloat
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

Formel Speicherbedarf Float
Speicher = Anzahl · ByteProFloat

Umstellungen:
    Anzahl       = Speicher / ByteProFloat
    ByteProFloat = Speicher / Anzahl

Die Variablen

SymbolBedeutungEinheitErklärung
AnzahlAnzahl WerteAnzahl der Float-Werte.
ByteProFloatByte pro FloatByteBytes pro Wert (4 oder 8).
SpeicherSpeicherbedarfByteGesamter Speicherbedarf.

Minimal-Beispiel

1024 float64-Werte:

Rechnung 1024 · float64
Speicher = 1024 · 8
         = 8192 Byte
         = 8 KiB

Praxis-Beispiele

Beispiel 1 — Audio-Sample-Buffer

48.000 float32-Samples (1 s bei 48 kHz mono):

Rechnung 48 kHz · 1 s
Speicher = 48.000 · 4
         = 192.000 Byte
         ≈ 187,5 KiB

Beispiel 2 — Numerisches Gitter

Ein 2D-Gitter 1024 × 1024 als float64-Matrix:

Rechnung 1024² Matrix
Speicher = 1024 · 1024 · 8
         = 8.388.608 Byte
         = 8 MiB

Beispiel 3 — Speicher → Anzahl

Wie viele float32-Werte passen in 1 MiB?

Rechnung 1 MiB / float32
Anzahl = 1.048.576 / 4
       = 262.144 Werte