Autor Beitrag
le Cauchemar
ontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 24

Win XP
C#
BeitragVerfasst: Sa 26.12.09 16:54 
Guten Tag,
Ich schreibe gerade ein Programm, bei dem es nötig ist, die 3. Wurzel aus einer Variablen zu ziehen, aber irgendwas mache ich falsch...
Nehmen wir als Beispiel die 3. Wurzel aus 27:
Da es in der Math-Klasse keine Methoden zum Ziehen einer beliebigen Wurzel gibt und man den Term so schreiben könnte 27 ^ (1/3), gehe ich davon aus, dass der Code wie folgt aussehen müsste
ausblenden C#-Quelltext
1:
Math.Pow(271/3)					

Das Ergebnis erhalte ich allerdings 1, statt 3.
Kann mir jemand sagen, wo mein Fehler liegt? :/

Moderiert von user profile iconChristian S.: Code- durch C#-Tags ersetzt
Moderiert von user profile iconChristian S.: Topic aus Sonstiges (.NET) verschoben am Sa 26.12.2009 um 16:00
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Sa 26.12.09 16:59 
1/3 ist eine Integer-Division und ergibt somit 0. Du musst 1.0 / 3.0 nehmen.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
le Cauchemar Threadstarter
ontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 24

Win XP
C#
BeitragVerfasst: Sa 26.12.09 17:01 
Oh ._.
Vielen Dank, jetzt klappt's ^^'