Thema: Delphi Rechnen

Einzelnen Beitrag anzeigen

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