Autor Beitrag
mcdust
Hält's aus hier
Beiträge: 2

Win XP
D6 prof
BeitragVerfasst: Mi 21.07.04 15:48 
hallo ich bin neu hier und hoffe das ist das richtige forum für meine frage:
wie bekomme ich aus z.B. 13,5 die 5 als normalen integer wert zum ausgeben??
es geht nur um die erste nachkommastelle..
für hilfe wär ich echt dankbar!!!
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Mi 21.07.04 15:52 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
function ErsteNachkommastelle(r:real):integer;
begin
  Result:=Trunc(r*10MOD 10;
end;


Cu,
Udontknow
TheNeon
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 408

Windows
VS2010 C#
BeitragVerfasst: Mi 21.07.04 16:07 
oder falls es beliebige Nachkommastellen sind:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
function TForm1.Nachkommawert(wert: real): Integer;
begin
  result := strtoint(  RightStr(  floattostr(wert), Length(floattostr(wert)) - Pos(',', floattostr(wert))  )  );
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit1.Text := inttostr(Nachkommawert(123.456));
end;



Bye,
TheNeon :twisted:
mcdust Threadstarter
Hält's aus hier
Beiträge: 2

Win XP
D6 prof
BeitragVerfasst: Mi 21.07.04 19:47 
WOW so schnelle hilfe vielen dank auch wenn ich das mit den prozeduren noch nicht ganz verstehe habs hinbekommen mit
"rest:=Trunc(rest*10) MOD 10;"
vielen dank nochmal!!!