bin vielleicht nicht ganz am richtigen Ort.
Es scheint(Ausprobieren), dass man in Python einfach so mit grossen ganzen Zahlen rechnen kann, ohne spezielle Vorungen o zu machen. Stimmt das so,gibt es Einschränkunge, wie zB Anzahl Stellen, oder Empfehlungen?
märssi
grosse Zahlen
So ist es. Seit Python 3 oder so passt Python den Speicherbedarf von Nummern automatisch an - eine Erklaerung findet sich zB hier: https://www.codementor.io/@arpitbhayani ... 12icwon5vk
- __blackjack__
- User
- Beiträge: 13268
- Registriert: Samstag 2. Juni 2018, 10:21
- Wohnort: 127.0.0.1
- Kontaktdaten:
Das ist schon seit Python 2.2 so gewesen, das `int` automatisch zu `long` wurden und es keinen `OverflowError` mehr gab. Also seit fast 21 Jahren. Mit Python 3 wurde dann der extra Datentyp `long` abgeschafft. Oder besser gesagt das alte `int` wurde abgeschafft und durch `long` ersetzt das jetzt `int` heisst.
Please call it what it is: copyright infringement, not piracy. Piracy takes place in international waters, and involves one or more of theft, murder, rape and kidnapping. Making an unauthorized copy of a piece of software is not piracy, it is an infringement of a government-granted monopoly.
Und das gilt natürlich nur für ganze Zahlen. Der Datentyp `float` in Python ist das, was in anderen Sprachen `double` oder `f64` heißt: Eine 64-Bit-Gleitkommazahl mit begrenzter Genauigkeit:
Code: Alles auswählen
>>> x = float(2 ** 54)
>>> x
1.8014398509481984e+16
>>> x == x + 1
True