Thread Memory overflow?
(2 answers)
Opened by Mike at 2011-10-18 17:18
Sorry, hatte im Reflex das 'ne' durch '!=' ersetzt, nur dann stimmt das unten gesagte. Ansonsten funktioniert Dein Code nur bei negativen Zahlen nicht.
edit: Weiterlesen zwecklos, Thema verfehlt Hi, Du erhältst bei nicht ganzzahligen Ergebnissen eine Endlosschleife, weil Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 use strict; use warnings; my $zahl = 2; my $i = 1; my $q = 1; while ($q ne $zahl) { $q = $i * $i; $i = (($q + $zahl)/$i)/2; print "$i\n"; } printf("\n\$zahl:%6d\n\$i: %.18f\n\$q float: %.18f\n\$q string: %s\n", $zahl, $i, $q, $q ); print "Wurzel von $zahl ist $i.\n\n"; Code: (dl
)
1 1.5 Gruß FIFO Editiert von FIFO: falsche Begründung Last edited: 2011-10-19 10:29:01 +0200 (CEST) Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it? -- Brian Kernighan: "The Elements of Programming Style"
|