Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Int64 in Float (https://www.delphipraxis.net/10610-int64-float.html)

Akut-Programming 22. Okt 2003 08:59


Int64 in Float
 
Hi, noch n Problem.. :mrgreen:

wie bekomm ich einen Int64 in eine Gleitkommazahl?

Grüße aus Halle,

Ghostwalker 22. Okt 2003 09:13

Re: Int64 in Float
 
Einfache Frage einfache Antwort:

Zuweisen :mrgreen:

Code:
function Int64ToExtend(AInt:Int64):Extended;
begin
  result := AInt;
end;

Sharky 22. Okt 2003 09:15

Re: Int64 in Float
 
Zitat:

Zitat von Akut-Programming
Hi, noch n Problem.. :mrgreen:

wie bekomm ich einen Int64 in eine Gleitkommazahl?

Grüße aus Halle,

Imho geht das nicht. Ein Int64 ist ja der "größte" Zahlentyp.

Lasse mich aber gerne belehren!!

[EDIT]
:wall: :wall:

Extended habe ich ja total vergessen

[/EDIT]

Akut-Programming 22. Okt 2003 09:17

Re: Int64 in Float
 
Hmm Schade, hmm okay dann gibts nur ne KB Angabe im Prog! :lol: THX!

Christian Seehase 22. Okt 2003 09:39

Re: Int64 in Float
 
Moin Zusammen,

und ab nach "Sonstiges" ;-)

Ghostwalker 22. Okt 2003 09:50

Re: Int64 in Float
 
Ich habs jetzt einfach mal ausprobiert und es geht:

Code:
Procedure test;
var
  aInt : Int64;
  aExt : extended;

begin
  aInt := High(Int64);
  aExt := Aint;
end;

:bouncing4: :bouncing4: :bouncing4:

endlich darf ich auch mal schlauer sein. :mrgreen: :mrgreen:

himitsu 22. Okt 2003 09:50

Re: Int64 in Float
 
Int64 ist der größte Integer.

Int64 => Double, Extended, Comp

Aus der OH:
Delphi-Quellcode:
Reelle Typen:
  Real48             2.9 x 10^-39 .. 1.7 x 10^38             6 Byte / 48 Bit
  Single            1.5 x 10^-45 .. 3.4 x 10^38             4 Byte / 32 Bit
* Double           5.0 x 10^-324 .. 1.7 x 10^308            8 Byte / 64 Bit
* Extended        3.6 x 10^-4951 .. 1.1 x 10^4932          10 Byte / 80 Bit
* Comp                   -2^63+1 .. 2^63 -1                 8 Byte / 64 Bit
  Currency -922337203685477.5808 .. 922337203685477.5807    8 Byte / 64 Bit

Integer-Typen:
  Shortint                  -128 .. 127                     1 Byte /  8 Bit
  Smallint                -32768 .. 32767                   2 Byte / 16 Bit
  Longint            -2147483648 .. 2147483647              4 Byte / 32 Bit
* Int64                     -2^63 .. 2^63-1                  8 Byte / 64 Bit
  Byte                         0 .. 255                     1 Byte /  8 Bit
  Word                         0 .. 65535                   2 Byte / 16 Bit
  Longword                     0 .. 4294967295              4 Byte / 32 Bit
Zitat:

Der Typ Comp (für "computational") ist ein natives Format der Intel-Prozessorarchitektur und stellt einen 64-Bit-Integer dar. Er ist dennoch als reeller Typ klassifiziert, weil sein Verhalten nicht dem eines ordinalen Typs entspricht. Ein Comp-Wert kann beispielsweise weder inkrementiert noch dekrementiert werden. Comp ist nur aus Gründen der Abwärtskompatibilität vorhanden. Eine höhere Ausführungsgeschwindigkeit erhalten Sie mit dem Typ Int64.

Ghostwalker 22. Okt 2003 17:06

Re: Int64 in Float
 
Schön, schön....himitsu..nur...was willst du mir damit sagen :wiejetzt:


Mein Compiler mekkert nicht bei der Prozedur noch gibts zur laufzeit nen Fehler.

himitsu 22. Okt 2003 23:55

Re: Int64 in Float
 
Das war keine Anwort auf deinen letzten Eintrag hier. (schau mal auf die Uhrzeit)
Es war mehr als Entscheidungshilfe für deine Wahl eines passenden reelen Typen und als Antwort auf Sharky's Beitrag gedacht.
Zitat:

Int64 ist ja der "größte" Zahlentyp - Extended habe ich ja total vergessen
2^63 ~ 9.2 x 10^19 was zeigt, das alle reellen Typen (ausser Currency) einen grösseren Wertebereiche besitzen.

Wenn du auf Comp umsteigst, kannst'e auch 'ne schellere Art der Typenumwandlung verwenden.
Da Comp und Int64 intern das selbe Format zur Speicherung nutzen.
Delphi-Quellcode:
Var C: Comp;
    I: Int64;
Delphi-Quellcode:
C := Comp(I);
{oder}
I := Int64(C);
An sonsten bist'e mit Extended (wegen der Genauigkeit) auf 'nem guten Weg.
Denn je kleiner der Typ (Größe in Byte), desto grösser ist die Ungenauigkeit. Bei Int64 zu Single sind das immerhin bis zu 37 Milliarden.


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:30 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz