![]() |
Zahlenformate
Hallo,
ich habe eigentlich eine banale Frage, aber trotz intensiver Suche habe ich hier noch nicht die passende Antwort gefunden. Also von TurboPascal kenne ich noch den Befehl "write(Zahl:3:2)", um z.B. eine REAL-Variable mit 2 Stellen hinter dem Komma auszugeben. Wie mache ich das in Delphi ? Z.B. von einer Variable SINGLE ?
Delphi-Quellcode:
Danke für eine Antwort!
L,B,A1: integer; A2:single
A1:=l*b; A2:=A1/100; Flaeche.text:= IntToStr(A1); Flaeche_cm.text:= FloatToStr(A2) |
Re: Zahlenformate
Moin Nephilim,
schau Dir dazu in der Hilfe mal ![]() ![]() ![]() |
Re: Zahlenformate
Hallo Christian,
meinst du das hier: Format Strings A format string is an interpreted token that the NDR engine understands. Format strings are often referred to as MOPs; this documentation uses the term format string throughout. To be more precise, a format character is an individual (atomic) interpretable token. Each format character is one byte in size. A format string is a sequence of format characters or format characters and numerical data. The term descriptor is also used for naming common sequences; for example, a parameter format string or a parameter descriptor is a format string used to describe a parameter of a routine. Format characters have suggestive symbolic names like FC_LONG or FC_STRUCT. All format string characters used by MIDL and the NDR engine are defined in the Ndrtypes.h file. Format String Tables Two primary format string tables are used by the engine: the procedure format string table, __MIDL_ProcFormatString, that keeps the procedure descriptors; and the type format string table, __MIDL_TypeFormatString, that keeps the data type descriptors. The compiler generates both into the main stub files (*_c.c, *_s.c, *_p.c). The procedure format string table is used mostly by various interpreters but it is also used for the buffer conversion regardless of the compiler mode. The type format string table is used when calling the core NDR engine to indicate specific data types to be worked on. Format String Notation The notation used in this document follows common programming description guidelines, with a bar ( | ) used to denote alternative constructs and square brackets ( [ ] ) used to indicate optional elements. Format strings are frequently stacked up for readability (accountability). Throughout this document, FC denotes a single format character. Format characters are presented in all CAPS, using their actual symbolic names. Other arbitrary fields are represented by a name and a size. Angle brackets ( <> ) are used to denote sizes of the descriptors. The conventions shown in the following table are employed. :shock: Zeigt mir - sorry - jetzt nicht wie ich es machen muss ?! Warum ist das bei DELPHI so kompliziert geworden :( Gruss NEPHI |
Re: Zahlenformate
Zitat:
Delphi-Quellcode:
FormatFloat('0.0#', -17.37777777777) = '-17,38'
|
Re: Zahlenformate
So ähnlich geht es mit Delphi auch noch, und zwar mit dem Str-Befehl, glaube ich. Format ist halt praktisch die neuere Variante. Mächtiger. Besser. Und auch nicht wirklich schwer zu verstehen.
|
Re: Zahlenformate
Delphi-Quellcode:
D.h. ich muss das Ergebnis kennen - in deinem Bsp. -17.3777 - und dann umwandeln?
FormatFloat('0.0#', -17.37777777777) = '-17,38'
Nein oder? Für -17,37777 muss ich dann wohl die Variablen-Bezeichnung eintragen ? Für was steht das '0.0#' ? Gruss Nephi |
Re: Zahlenformate
Zitat:
|
Re: Zahlenformate
Ich frag doch hier :?: - die Hilfe kann man überwiegend vergessen!
|
Re: Zahlenformate
Zitat:
|
Re: Zahlenformate
Danke für die copy :-D
Aber am Anfang der Hilfe steht das: Formatiert einen Gleitkommawert. Namespace Borland.Vcl.SysUtils Syntax [Delphi] function FormatFloat(const Format: string, Value: Extended): string; [Delphi] function FormatFloat(const Format: string, Value: Extended, const FormatSettings: TFormatSettings): string; [Delphi] function FormatFloat(const Format: string, Value: Extended, Provider: IFormatProvider): string; Und ehrlich gesagt habe ich da, die Formatierung, wie oben nicht erkennen können. Ich habe es inzwischen so gelöst : [pre][pre][/pre]A1:=l*b; //Fläche in mm² A2:=A1/100; gewicht:=kg*A2; Flaeche.text:= IntToStr(A1); Flaeche_cm.text:= FloatToStr(A2); Flaeche_cm.text := FloatToStrF(StrToFloat(Flaeche_cm.text),ffNumber,5 ,2)[delphi] Mal eine andere Frage: Kann ich das Buch "Borland Delphi 7 - Grundlagen, Profiwissen, Kochbuch. Das umfassende Handbuch für die Win32-Anwendungsentwicklung" auch für DELPHI 2005 was ich habe kaufen? Ich suche immer noch ein g´scheites Buch mit Grundlagen von DELPHI 2005 (komme direkt aus der TurboPascal 6-Welt). Danke für eine Info und danke für die Tipps! |
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:26 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-2025 by Thomas Breitkreuz