# rounding decimals

## Recommended Posts

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.

```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
For \$noemer = 1 To \$aantal
ProgressSet( \$noemer / \$aantal * 100, Round (\$noemer / \$aantal * 100, 1) & "%")
\$temp = 1 / (\$noemer ^ 2)
Next
EndIf
ProgressOff()
\$pi = Sqrt(\$stap1)
If MsgBox(325, "uitkomst", "Volgens je benadering:" & @CRLF & "pi=" & \$pi) = 2 Then
Exit
EndIf
WEnd```

```\$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)```

```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
For \$noemer = 0 To \$aantal
ProgressSet( \$noemer / \$aantal * 100, Round (\$noemer / \$aantal * 100, 1) & "%")
\$faculteit = faculteit(\$noemer)
\$temp = 1 / \$faculteit
Next
EndIf
ProgressOff()
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```

##### Share on other sites

Found in helpfile

The decimalplaces parameter can be negative which allows you to round to the ones, tens, hundred, etc. place. Note that up to fifteen digits of a number are displayed, and note that decimalplaces will never pad a number with trailing zeros.

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-CafĂ© Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

##### Share on other sites

I don't understand what you're doing, but slightly changed

```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.")
If @error Or \$aantal < 1 Then Exit
If Not StringIsDigit(\$aantal) Then ContinueLoop
ProgressOn("Berekenen", "Vooruitgang", 0)

\$tmp = 0
For \$i = 0 To \$aantal
; If Not Mod(\$i, 10) Then
\$tmpCur = Int(\$i / \$aantal * 100)
If \$tmpCur > \$tmp Then
ProgressSet(\$tmpCur, \$tmpCur & "%")
\$tmp = \$tmpCur
EndIf
\$faculteit = faculteit(\$i)
Next

ProgressOff()
If MsgBox(325, "uitkomst", "Volgens je benadering:" & @CRLF & "e=" & \$e) = 2 Then Exit
WEnd

Func faculteit(\$nummer)
Local \$n = 1

For \$i = 1 To \$nummer
\$n *=\$i
Next

If \$n Then
Return \$n
Else
Return SetError(1, 0, 1)
EndIf
EndFunc   ;==>faculteit```

## Create an account

Register a new account