二进制到标准数字?

发布于 2024-09-26 12:46:31 字数 234 浏览 7 评论 0 原文

我要在一台计算机 .minecraft.net/" rel="nofollow">我的世界。我了解如何构建一台可以进行二进制运算的计算机,但我希望输出显示为标准整数。如何将二进制文件“转换”为标准数字?有相关图表吗?并且数字将像旧计算器一样显示;有7行。

 --
|  |
 --
|  |
 --

I'm going to make a computer in Minecraft. I understand how to build a computer where it can make binary operations but I want the outputs to be displayed as standard integer numbers. How you "convert" the binaries into standard digits? Is there any chart for that? And the digits will be shown like in old calculators; with 7 lines.

 --
|  |
 --
|  |
 --

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

怂人 2024-10-03 12:46:31

在电子学中,您需要的是所谓的“二进制到二进制编码的十进制”转换器。 “二进制编码的十进制”是在 7 段显示器上生成数字所需的一组位。 这里有一个 PDF 描述其中一款芯片的工作原理。 PDF 第 3 页显示了进行转换所需的真值表以及在硬件中实现该转换的所有 NAND 门的图片。您可以使用真值表来构建程序中所需的布尔表达式集。

In electronics, what you need is called a "binary to binary coded decimal" converter. "Binary coded decimal" is the set of bits needed to produce a number on a 7 segment display. Here's a PDF describing how one of these chips works. Page 3 of the PDF shows the truth table needed to do the conversion as well as a picture of all of the NAND gates that implement it in hardware. You can use the truth table to build the set of boolean expressions needed in your program.

谎言 2024-10-03 12:46:31
0 = 0
1 = 1
10 = 2
11 = 3
100 = 4
101 = 5
110 = 6
111 = 7
...

你看到这个模式了吗?公式如下:

number = 2^0 * (rightmost digit)
       + 2^1 * (rightmost-but-1 digit
       + 2^2 * (rightmost-but-2 digit) + ...
0 = 0
1 = 1
10 = 2
11 = 3
100 = 4
101 = 5
110 = 6
111 = 7
...

Do you see the pattern? Here's the formula:

number = 2^0 * (rightmost digit)
       + 2^1 * (rightmost-but-1 digit
       + 2^2 * (rightmost-but-2 digit) + ...
陌路终见情 2024-10-03 12:46:31

也许您正在寻找的称为 BCD 或二进制编码十进制。有一张图表和一张卡诺图,已经使用了几十年。快速谷歌搜索给了我这个技术页面

您打算如何组装计算机?
也许这个关键词至少可以帮助你找到你需要的东西。 :)

Maybe what you are looking for is called BCD or Binary Coded Decimal. There is a chart and a karnaugh map for it that has been used for decades. a quick Google search for it gave me this technical page
http://circuitscan.homestead.com/files/digelec/bcdto7seg.htm

How are you trying to build the computer?
Maybe that key word can at least help you find what you need. :)

愛放△進行李 2024-10-03 12:46:31

您的问题有两个部分:

  1. 将二进制数转换为数字,即进行二进制到 BCD 的转换。

  2. 将数字转换为一组要激活的段。

对于后者,您可以使用 将活动段的位图分配给每个段的表数字

Your problem has two parts:

  1. Convert a binary number into digits, that is do a binary to BCD conversion.

  2. Convert a digit into a set of segments to activate.

For the latter you can use a table that assigns the bitmap of active segments to each digit.

蓝海 2024-10-03 12:46:31

我认为这是两个不同的问题。

没有内置的“0/1 二进制字符串”到整数转换 - 您通常只需编写自己的字符串来循环并检测 2 的每个幂。

您还可以编写自己的 7 段 LED 显示屏 - 这是一个有点棘手,因为它有多行,但将是一个有趣的练习。

另外,大多数 GUI 都有 LCD 字体,Qt 当然也有

I think's that's two different questions.

There isn't a "binary string of 0/1" to integer conversion built in - you would normally just write your own to loop over the string and detect each power of 2.

YOu can also write your own 7segment LED display - it's a little tricky because it's on multiple lines, but would be an interesting excersize.

Alternatively most GUIs have an LCD font,Qt certainly does

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文