Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

rounding decimals

$
0
0
Hello,

Currently I am encountering a problem with my script concerning decimal numbers.
The problem is that the program rounds a number to a certain amount of decimals but I want more.
Is there a way I can manipulate / change this?

Here are the scripts.

[ autoit ]      
While 1 $aantal = InputBox("Invoer", "Vul in hoeveel berekeneningen de computer moet uitvoeren." & @CRLF & "Hoe groter het getal hoe meer het van je computer vraagt.") ProgressOn ("Berekenen", "Vooruitgang", 0) If $aantal = 0 Then Exit Else $benadering = 0 For $noemer = 1 To $aantal ProgressSet( $noemer / $aantal * 100, Round ($noemer / $aantal * 100, 1) & "%") $temp = 1 / ($noemer ^ 2) $benadering = $benadering + $temp Next EndIf ProgressOff() $stap1 = $benadering * 6 $pi = Sqrt($stap1) If MsgBox(325, "uitkomst", "Volgens je benadering:" & @CRLF & "pi=" & $pi) = 2 Then Exit EndIf WEnd
$pi needs to be adapted
[ autoit ]      
 $vraag=MsgBox(4, "Start", "Bereken phi?") If $vraag = 7 Then Exit EndIf $stap1 = Sqrt(5) $stap2 = 1 + $stap1 $stap3 = $stap2 / 2 $phi = $stap3 MsgBox(64, "uitkomst", "pi=" & $phi)
$phi needs to be adapted
[ autoit ]         
While 1 $aantal = InputBox("Invoer", "Vul in hoeveel berekeneningen de computer moet uitvoeren." & @CRLF & "Hoe groter het getal hoe meer het van je computer vraagt.") ProgressOn ("Berekenen", "Vooruitgang", 0) If $aantal = 0 Then Exit Else $benadering = 0 For $noemer = 0 To $aantal ProgressSet( $noemer / $aantal * 100, Round ($noemer / $aantal * 100, 1) & "%") $faculteit = faculteit($noemer) $temp = 1 / $faculteit $benadering = $benadering + $temp Next EndIf ProgressOff() $e=$benadering If MsgBox(325, "uitkomst", "Volgens je benadering:" & @CRLF & "e=" & $e) = 2 Then Exit EndIf WEnd Func faculteit($nummer) Local $n = 1.0 For $i = 1 to $nummer $n = $n*$i Next If $n = 0 Then SetError ( 1 ) Return 1 Else Return $n EndIf EndFunc
$e needs to be adapted

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>