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

WindowsXP
Object Pascal, Delphi 7 Prof
BeitragVerfasst: So 08.07.07 21:37 
Hi Leute!

Vllt kann hier jemand weiterhelfen, und mir nen Tip geben, mit welchem Befehl ich einen berechneten Wert auf eine volle Zahl aufrunden bzw. abrunden kann.

Gruß Paddybär :D
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 08.07.07 21:38 
ausblenden Delphi-Quelltext
1:
Trunc( Wert + 0.5)					

_________________
Markus Kinzler.
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: So 08.07.07 21:43 
Mit round kannste mathematisch korrekt auf- und abrunden, ceil rundet immer auf, floor immer ab.

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
paddybär Threadstarter
Hält's aus hier
Beiträge: 2

WindowsXP
Object Pascal, Delphi 7 Prof
BeitragVerfasst: So 08.07.07 22:19 
vielen dank euch beiden :roll:
Shorty
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 107

Win XP, Ubuntu 8.04
Delphi 7 Prof., Delphi 2005 Pers.
BeitragVerfasst: Mo 09.07.07 14:50 
user profile iconjakobwenzel hat folgendes geschrieben:
Mit round kannste mathematisch korrekt auf- und abrunden, [..]

Naja nicht ganz: Als Ergebnis der round-Funktion für 12.5 spuckt Delphi 12 aus und für 17.5 18 :roll:
Hat was damit zu tun, ob die Vorkommawert gerade oder ungerade ist, wenn der Nachkommawert genau 0.5 ist, bei einem geradem Vorkommawert wird abgerundet, bei einem ungeraden dagegen auf...

Ich seh grad in der Delphi-Hilfe:
Delphi-Hilfe hat folgendes geschrieben:

Liegt X genau in der Mitte zwischen zwei ganzen Zahlen, wird immer die gerade Zahl zurückgeliefert.


Mathematisch korrekt ist bei mir was anderes :wink:

MfG Shorty
Agawain
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 460

win xp
D5, MySQL, devxpress
BeitragVerfasst: Mo 09.07.07 15:00 
Hi

Ne, das ist mathematisch korrekt.

de.wikipedia.org/wiki/Rundung

guckst Du da

Gruß

Aga
Jakob Schöttl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 929
Erhaltene Danke: 1


Delphi 7 Professional
BeitragVerfasst: Mo 09.07.07 15:06 
user profile iconAgawain hat folgendes geschrieben:
Hi

Ne, das ist mathematisch korrekt.

de.wikipedia.org/wiki/Rundung

guckst Du da

Gruß

Aga


Stimmt, bei Wikipedia steht das so...

komisch, warum lernen wir in der Schule das immer anders? :nixweiss:
Allesquarks
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 510

Win XP Prof
Delphi 7 E
BeitragVerfasst: Mo 09.07.07 15:09 
Das abwechselnd auf und abrunden ist bei Statistik und Fehlerrechnung sehr wichtig, da durch immer aufrunden sich ein systematischer Fehler einschleichen könnte. Die Regel aus der Schule immer aufrunden ist ja nicht falsch sondern nur für ein anderes Aufgabenfeld.