Einzelnen Beitrag anzeigen

Benutzerbild von himitsu
himitsu
Online

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.164 Beiträge
 
Delphi 12 Athens
 
#3

Re: Extended To String mit dekadischen Einheiten

  Alt 23. Jun 2009, 16:06
Zitat:
Result := '0.000 '+OutString;
und was ist, wenn bei ich bei accuracy was anderes wollte, und nicht .000 ?

Zitat:
Delphi-Quellcode:
frmt := '%.'+IntToStr(accuracy)+'f %s';
Format(frmt, [Value, S])
da gibt es so ein knuffiges *
Format('%.*f %s', [accuracy, Value, S])
Zitat:
if (Value * Range) < 1 then Index := 9 + Exp else Index := Exp + 9;
9 + Exp oder Exp + 9 kommt bei mir aber auf's Gleiche raus

Delphi-Quellcode:
Const
ExpString : array[Boolean, 1..17] of String
  = (('Yokto', 'Zepto', 'Atto', 'Femto', 'Piko', 'Nano', 'Micro', 'Milli',
      '', 'Kilo', 'Mega', 'Giga', 'Terra', 'Peta', 'Exa', 'Zetta', 'Yotta'),
     ('y', 'z', 'a', 'f', 'p', 'n', 'µ', 'm',
      '', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'));

Result := Format('%.*f %s %s', [accuracy, Value / Power(10, Exp * 3),
  ExpString[Short, Index], OutString]);

// oder doch besser array[Boolean] of array[1..17] of String *grübel*
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat