![]() |
Delphi-Version: 10.2 Tokyo
Recordhelper - Was macht TDoubleHelper.Fraction?
Hilfe und DocWiki sagen zu TDoubleHelper.Fraction
Zitat:
Delphi-Quellcode:
und die Ergbenisse für Tokyo CE
program dhbug;
{$ifdef FPC} uses sysutils; {$else} {$apptype console} uses system.sysutils; {$endif} var x: double; y: extended; begin x := 0.75; y := x.fraction; writeln(x:20:10, y:30); x := 1.5; y := x.fraction; writeln(x:20:10, y:30); x := 2.5; y := x.fraction; writeln(x:20:10, y:30); end.
Code:
bzw. für FreePascal
D:\Work\TMP>D:\DMX\M2564\DCC64 -b dhbug.dpr
Embarcadero Delphi for Win64 compiler version 32.0 Copyright (c) 1983,2017 Embarcadero Technologies, Inc. dhbug.dpr(25) 26 lines, 0.05 seconds, 171384 bytes code, 62256 bytes data. D:\Work\TMP>dhbug.exe 0.7500000000 1.50000000000000000E+0000 1.5000000000 1.50000000000000000E+0000 2.5000000000 1.25000000000000000E+0000
Code:
FPC gibt also frac zurück. Aber Delphi? Ist das ein weiterer Bug?
D:\Work\TMP>D:\FPC311\bin\i386-win32\ppcrossx64.exe dhbug.dpr
Free Pascal Compiler version 3.1.1-r20:38794 [2018/04/22] for x86_64 Copyright (c) 1993-2018 by Florian Klaempfl and others Target OS: Win64 for x64 Compiling dhbug.dpr Linking dhbug.exe 24 lines compiled, 0.2 sec, 70112 bytes code, 5172 bytes data D:\Work\TMP>dhbug.exe 0.7500000000 7.5000000000000000E-001 1.5000000000 5.0000000000000000E-001 2.5000000000 5.0000000000000000E-001 Weiß jemand über die Hilfe hinaus, was die Funktion eigentlich liefern soll? PS: Ich sehe natürlich selbst, daß das Ergebnis laut Sourcecode
Delphi-Quellcode:
ist, aber was ist der Sinn? Warum wird 1 addiert, wenn man den Nachkommateil haben will?
Result := 1.0 + (F / $0010000000000000);
|
AW: Recordhelper - Was macht TDoubleHelper.Fraction?
Fraction ist nicht "DER" Nachkommateil, sondern wohl eher eine Fließkommadarstellung der Mantissa. :gruebel:
Und das auch noch teilweise abhängig davon, ob für 32 Bit oder 64 Bit kompiliert wurde. Hier die Interna, also was drinnen was bedeutet: ![]() Eigentlich festgelegt wie Normalisiert werden muß und demnach sollten doch Delphi und FPC das gleiche Ergebnis liefern. :gruebel: ![]() Irgendwie scheint ![]() ![]() ![]() |
AW: Recordhelper - Was macht TDoubleHelper.Fraction?
Zitat:
Zitat:
|
AW: Recordhelper - Was macht TDoubleHelper.Fraction?
Wie der TE schon bemerkt hat, ist TDoubleHelper.Fraction ein Wert zwischen 1 und 2. :angle:
Zitat:
|
AW: Recordhelper - Was macht TDoubleHelper.Fraction?
Zitat:
Code:
was ja wohl nicht zwischen 1 und 2 ist.
8.69169475979E-0311 3.90625000000000000E-0003
Edit: Ich habe mal gesucht: Die einzige Stelle in der RTL (außer system/sysutils), die das benutzt, ist Math.Frexp
Delphi-Quellcode:
D.h. X.Fraction ist das Doppelte der Mantisse, aber da stellt sich noch einmal mehr die Sinnfrage, zumal TDoubleHelper.Mantissa ja schon noch etwas anderes bedeutet.
procedure Frexp(const X: Double; var Mantissa: Double; var Exponent: Integer); overload;
... Mantissa := X.Fraction / 2; end; //Frexp returns the mantissa of X as Mantissa and the exponent as Exponent. |
AW: Recordhelper - Was macht TDoubleHelper.Fraction?
Zitat:
|
AW: Recordhelper - Was macht TDoubleHelper.Fraction?
Zitat:
Edit: OK falsche Funktion. Für .Exponent ergibt sich x.Exponent = -1022 und y.Exponent = -8 |
AW: Recordhelper - Was macht TDoubleHelper.Fraction?
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:37 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz