Autor Beitrag
sekingofsering
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: Mo 31.01.05 23:02 
hab ein Problem mit sinus

will denn sinus von Pi berechnen
also
x := sin (Pi);
aber delphi liefert als ergebnis -5,42.... statt 0
wieso was mache ich falsch

Moderiert von user profile iconTino: Titel geändert.
Socher
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45

warmes flüssiges Blut
D7 Prof, D8 Prof
BeitragVerfasst: Mo 31.01.05 23:33 
Das Ergebnis von sin(pi) = 0 und stimmt!

_________________
FREIHEIT
Elite
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 31.01.05 23:38 
Du musst dich beim Ablesen der Zahl ein wenig vertan haben. Bei mir steht nämlich das:
-5,42101086242752E-20
Das kommt der 0 dann doch schon ziemlich nahe.
sekingofsering Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: Mo 31.01.05 23:43 
wenn ich denn sin durch cos ersetzte lifert delphi -1 und stimmt aber wenn ich wieder sin schreibt liefert er ein falsches ergebniss
spinn ich was kann da sein
dreh gleich durch
sekingofsering Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: Mo 31.01.05 23:45 
danke ja stimmt kommt -5,42 e-20 raus mein fehler
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Di 01.02.05 22:04 
Das Ergebnis ist ein Rundungsfehler der FPU ... Dass er Cos(Pi) korrekt anzeigt liegt daran, dass 0,9999999999 999999999 56 einfach auf 1 gerundet wird, weil die FPU nur 20 Stellen hat. Bei 0,0000000000 0000000005 4 sieht das anders aus, da die Mantisse bei der 5 erst anfängt. Somit hast du hinter der 5 die ganzen Stellen und so einen geringen Exponenten.

Generell kannst Du alles, was Abs(Zahl) < 1E-15 ist getrost =0 annehmen.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.