Toy: Binary to Decimal

88 views
Skip to first unread message

Iván Nieto

unread,
Jul 3, 2011, 8:13:45 PM7/3/11
to Tile Factory
Input in the third row, maximum 524287. It needs heavy optimization:
for a number N, it takes a little more than N seconds to start the
output, so don't try huge numbers.

Example with 42:

eNod1geyrDgSQFGEkUlZZNB7v2z37Gk2O5ubyw/ilAClKEwqQS
3Lz3/U//SiRS8uhEVsXILEJbLtRSvv9ZKCqJBFxfy7RhlrEN23
oDfsOKBh4GDhERAhSMgoW3B9EbdhxwENAwsHgQcn4yISMgpOVL
RF9MnxKtoWzFjFDIVFzHpjfWWfwoIL827pmzf6F9qFVtEq2kvJ
topsSpIol8PmfN4dMRv9WDFwYW5cg+IacEDDwMJB4BEQkZBRcK
KioSsJu7fBIqCgY48uWAQU9OjSHiRZBBR0nsMmSCLGO8lomLdo
pSHDw0QbDc/VI6MFEfEuSuAahGuAhoGFAxGOMII4f2QUnKho6B
i4MLEnjgUNAwsGO26p8wiISMgoOFHR0DFwYSbZloITFQ1d1Jp5
JkaUuvuHqI3U3HFAw8Dm+xHyFPLf1HXLLstycMxd1nmkZcnJqV
OWtciyYccBDQMLLnYRhPscLgnr6cPa0DFQcXnlsyyeG6NKiCoz
Z66QtlPSVtHQMcAxjupIWhcMLBwEHgERCRkFJyoaOgau6sZ1yh
joaKg4UZCREBHgIeDBDQsDjYMHeXXHQcgbdJwoyEg4oGFg4SDw
CIio3cVjSNQwsCApqBTkGwIiEjIKTlQ0dAxcg9xp5A4MLEgyTo
7cQUBERkHCiYqGjoGriV4/eOMPHnjiJUH9SUE98MQLb3zSWD4y
ljf+4IEnXiLpkyS98QcPPPFKevt1escBDQMLBw9B+GV6/RPFQ+
BgYaBxYMf2DxP8yzVC4GBhoHFgx/bleb65n/9yXyFwsDDQOLBj
Q37hiQf+4IO3rDv3Wf3KVt5ylA//e3vjhSce5P0HL7zxxIP4l6
zXJetAR0PFiYyChIgADwHFYbUw0DguWcaUpaOh4kRBRkJEgIeA
4rJYGGgcU7ader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br90vjG/xetv9+a7R/vlU/4bonxL9N8eydpO5nWe
bOdpdZ5C5w537mDnLnXuRufKO1faubrOVXWuqB/z6Mya2ic1h7
b9RRmZvTIrMHCvt8pMAd+FbJ9/t2tlBmGgo+Hed1ZmFwY6Giru
/aUy+zDQ0VBx4u7LlRmKgY6GihMFd3+qzGQMdDRUnCjIuGNiZd
ZjoKOh4kRBRsIdFypVAgMdDRUnCniNEEvm4Y7l85p4KgP4jCae
WQc+r4kn48FnN/FkJO54qVQkDHQ0VJwoSMiICPC4x7hKNcNAR0
PFiYKMhIgAD8E9zlaqIQY6GipOFGQkRAR4CBzusaZSUTHQ0VBx
oiAjISLAQ+BgcY/XtTzLiwy/1p/wu/54CBwsDDQO7Nh+18nvz/
rDN853+T8ugeGy

CJ

unread,
Jul 4, 2011, 4:56:29 AM7/4/11
to tile-f...@googlegroups.com
Ah yes! Combine this, binary adder/subtracter, and the binary multiplier, and we can make a calculator! We still don't have the binary divider though.

CJ

unread,
Jul 4, 2011, 4:57:06 AM7/4/11
to tile-f...@googlegroups.com

steve42

unread,
Jul 4, 2011, 9:54:14 PM7/4/11
to Tile Factory
On Jul 4, 1:13 am, Iván Nieto <ivan.niet...@gmail.com> wrote:
> Input in the third row, maximum 524287. It needs heavy optimization:
> for a number N, it takes a little more than N seconds to start the
> output, so don't try huge numbers.

My version - avoids the operator having to scroll the level, so it's
"easier to see what's going on" because it's all on the screen at the
same time!
It processes a number up to 1599999 as binary input on the top row.
The time taken is constant, whatever number is entered. As there is
only space for 6 digits on the output, a black dot is painted at the
end to indicate an overflow (i.e. a first digit of 1). There's a bug I
couldn't be bothered to fix (as I only noticed it as I was writing
this, having already copy-pasted the level into the message box) which
causes it to crash if you ask it to process a number equal or greater
than 1600000. Easiest fix would be to put some other object over where
the highest bit would go, and declare the maximum input to be 1048575.

Example shown has input 1234567.

The intermediate representation is BCD ("binary coded decimal"). It
takes more time to get the "human-readable" version than to convert
the number to a form of decimal in the first place....

eNollweiJCcOQIkqoqh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lwaT2ReiOxPbcu923
sRRzFxF9wDIYYDq2y3sgf+XzJ5M3PvhBsa8x+gWe0M2EP/HWAn
CPHh2vmgGz9jLIQpz34rjoE+TASj8p6qNsZ0yf3/3/8A1meCAA
==

steve42

unread,
Jul 5, 2011, 4:45:22 PM7/5/11
to Tile Factory
On Jul 5, 2:54 am, steve42 <googlegro...@banoffee.co.uk> wrote:
> There's a bug I
> couldn't be bothered to fix (as I only noticed it as I was writing
> this, having already copy-pasted the level into the message box) which
> causes it to crash if you ask it to process a number equal or greater
> than 1600000.

As well as this bug, there's also a couple of "deliberate" errors for
you to find, which only show up when there are certain digits in
certain places... (a couple of wires missing from the central "None")
Reply all
Reply to author
Forward
0 new messages