## Recommended Posts

So I was testing myself by making a program that would convert Binary to Decimal. Check it out:

```Do
\$d = \$d / 5
Until (\$d < 1)
While (\$d <> 0)
\$d = \$d * 5
\$result = \$result + Int(\$d)
MsgBox(0,"Test1",\$d & "-" & Int(\$d) & "=" & (\$d - Int(\$d)))
\$d = \$d - Round(\$d)
MsgBox(0,"Test2",\$d)
WEnd```

Basically, \$d is the original Binary and \$result is going to be the decimal.

When I first ran it, It seemed to give me an infinite loop if I did a binary number over 4. That's why I put those Message Boxes in there, to see what's going on. I tried both Round() and Int() and both give me this same problem.

Anyway, somehow Test 1 is getting me equations like "1-1=3.2983049823e-18"(not exactly, but you get the picture), where I was expecting 0. Where is that tiny number even coming from? Can I get some help please?

Edited by PCode

##### Share on other sites

Mind posting an actual example and not some code that can't be ran without us putting our own information in?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

##### Share on other sites

It's nice to get a quick responce.

Attached is the uncompiled version of the script. Just type in 1000 in the binary for an example.

##### Share on other sites

Does this fix it?

```#include <GUIConstants.au3>

GUICreate("Encoder")
\$inpBin = GUICtrlCreateInput("Binary",5,5)
\$inpNorm = GUICtrlCreateInput("Normal",5,30)
;\$inpHex = GUICtrlCreateInput("Hexidecimal",5,55)
;\$inpNew = GUICtrlCreateInput("Superdecimal",5,80)
\$btnTransfer = GUICtrlCreateButton("Transfer!!",5,105)
GUISetState()

While 1
\$msg = GUIGetMsg()
If \$msg == \$GUI_EVENT_CLOSE Then Exit
If \$msg == \$btnTransfer Then
\$d = \$nBin
\$result = 0
Do
\$d = \$d / 5
Until (\$d < 1)
While (\$d <> 0)
\$d = \$d * 5
\$result = \$result + Int(\$d)
MsgBox(0,"Test1",\$d & "-" & Int(\$d) & "=" & (\$d - Int(\$d)))
\$d = \$d - Int(\$d)
MsgBox(0,"Test2",\$d)
WEnd
GUICtrlSetData(\$inpNorm,\$result)
EndIf
WEnd```

Edit:

I see the numbers are too big... might want to look at autoits limits.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

##### Share on other sites

No. I don't even see how that is different.

Edit: Numbers too big? How is that the case? Let's take 1000

Do While

1000 / 5 = 200 / 5 = 40 / 5 = 8 / 5 = 1.6 /5 = 0.32

0.32 * 5 = 1.6

Int(1.6) = 1

1.6-1 = 0.6

.6 * 5 = 3

Int(3) = 3

3 - 3 = 0 (Last time I checked)

Nothing over 4 digits.

Edited by PCode

##### Share on other sites

No. I don't even see how that is different.

Edit: Numbers too big? How is that the case? Let's take 1000

Do While

1000 / 5 = 200 / 5 = 40 / 5 = 8 / 5 = 1.6 /5 = 0.32

0.32 * 5 = 1.6

Int(1.6) = 1

1.6-1 = 0.6

.6 * 5 = 3

Int(3) = 3

3 - 3 = 0 (Last time I checked)

Nothing over 4 digits.

Everything I was trying with Number was failing... but then I remembered a circumstance where someone else ran into an issue...

I might just be too tired to answer your question... but I found the thread (unfortunately 3.2.3 isn't released yet)

http://www.autoitscript.com/forum/index.php?showtopic=38502

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...