AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Rechnen

Offene Frage von "delphinia"
Ein Thema von delphinia · begonnen am 4. Jul 2006 · letzter Beitrag vom 4. Jul 2006
Antwort Antwort
delphinia

Registriert seit: 16. Feb 2006
444 Beiträge
 
Delphi 11 Alexandria
 
#1

Rechnen

  Alt 4. Jul 2006, 02:44
Habe Probleme mit der Komma rechnung

Das Problem ist zB::

das bei der Ausgabe
label_6.Caption := Format(const_6, [i1]);
Fehlerhaft werte Rauskommen - wegen diesem Komma ein wert zB bei 0,651452 wird mit 0 gerechnete Wichtig ist aber das auch mit den nachkommer gerechnet wird!


Mein Beispiel:
Delphi-Quellcode:
TIMER
var
  S1, ti1, ti2, ti3, i3b, i3c, i3d: string;
  i1, i2, i3a: Integer;

  f, f1, f2: Extended;
begin

  // AKTUELLE ZEIT IMMER ANZEIGEN
  label_3.Caption := Format(const_3, [FormatDateTime('dd.mm.yyyy', now), FormatDateTime('hh:mm:ss', now)]);
  now_timer.Interval := 1000;



 // Vergangene Zeit berechnen
  all_days := Abs(Now - Zeit1);
  ti1 := FormatDateTime('hh', Now - Zeit1);
  ti2 := FormatDateTime('nn', Now - Zeit1);
  ti3 := FormatDateTime('ss', Now - Zeit1);

  if Trunc(all_days) <= 0 then S1 := IntToStr(Trunc(all_days)) + ' Tage'
  else
    if Trunc(all_days) = 1 then S1 := IntToStr(Trunc(all_days)) + ' Tag'
    else
      if Trunc(all_days) > 1 then S1 := IntToStr(Trunc(all_days)) + ' Tage';

  label_4.Caption := Format(const_4, [S1]);
  label_5.Caption := Format(const_5, [ti1, ti2, ti3]);


  // PT
  i1 := Trunc(all_days) * 24 * 60;
  i1 := (StrToInt(ti1) * 60) + i1 + StrToInt(ti2);

  i1 := i1 div 60 div 24;
  i1 := i1 * StrToInt(UZigsTag);
  label_6.Caption := Format(const_6, [i1]);

  // UZ
  i2 := i1 div StrToInt(UZ);
  i2 := i2 * StrToInt(UC);
  label_7.Caption := Format(const_7, [i2]);


  // N UND T
  f := i1 * StrToFloat(UN);
  f1 := i1 * StrToFloat(UT);
  label_8.Caption := Format(const_8, [f, f1]);


  // Time
  i3a := i1 * StrToInt(Time); // Minunten gebraucht

  i3b := FormatDateTime('hh', i3a);
  i3c := FormatDateTime('nn', i3a);
  i3d := FormatDateTime('ss', i3a);

  label_9.Caption := Format(const_9, [i3b, i3c, i3d]);
end;
Doreen
Gruss Doreen
  Mit Zitat antworten Zitat
Benutzerbild von Kroko1999
Kroko1999

Registriert seit: 21. Apr 2005
Ort: Spremberg
455 Beiträge
 
Turbo Delphi für Win32
 
#2

Re: Rechnen

  Alt 4. Jul 2006, 07:33
(a) schau Dir mal folgende Funktionen an und Deine Quellen sollten einfacher und lesbarer werden:

DateTimeToString
DecodeTime

(b)wenn Du Integer nimmst wird es auch keine Nachkommastellen haben (Variable I1)!
Da sprach der Stumme zum Blinden: "Du wirst sehen ..."
oder
Wer lesen kann, ist klar im Vorteil!
  Mit Zitat antworten Zitat
oki

Registriert seit: 30. Dez 2002
Ort: Brandshagen
1.819 Beiträge
 
Delphi 2007 Professional
 
#3

Re: Rechnen

  Alt 4. Jul 2006, 07:37
Hi delphinia,

ich möchte dir ja gerne helfen, verstehe aber deine Frage nicht so richtig.
1. gib mal "const_6" bekannt,
2. wo wird mit dem Label gerechnet?

Dann ist die aussage von Kroko auch nicht zu verachten. Mit Integer ist nicht viel im Nachkomma-Bereich.

Gruß oki
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:47 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