两个16位数字的乘法-为什么结果为32位长? [英] Multiplication of two 16-bit numbers - Why is the result 32-bit long?

查看:822
本文介绍了两个16位数字的乘法-为什么结果为32位长?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我将两个16位数字相乘,结果将是32位长.但是为什么会这样呢? 对此的明确解释是什么?

据我正确的理解: 计算方法是:将n位数字乘以m位数字得出(n + m)位数字?

解决方案

(2 n -1)*(2 m -1)= 2 n + m -2 n -2 m + 1

-(2 n + 2 m )就像清除索引 n m ,与2 n + m 相比,对结果的影响不大,因此您需要n + m位来表示结果.

例如 1111 2 * 1111 2 = 11100001 2 (15 * 15 = 225)

通常(b n -1)*(b m -1)= b n + m -b n -b m + 1 ,因此在任意基数 b 中将n位数字乘以m位数字最多n + m个数字

您可以轻松地以10为底: 9 * 9 = 81 (1位* 1位= 2位)或 99 * 99 = 9801 (2位) * 2位= 4位)

If I multiplie two 16-bit numbers, the result will be 32-bit long. But why is this so? What is the clear explanation for this?

And for my right understanding: The calculation for this is: n-bit number multiplied with a m-bit number gives a (n+m) bit number?

解决方案

(2n - 1)*(2m - 1) = 2n+m - 2n - 2m + 1

-(2n + 2m) is like clearing the bits at index n and m, which does not affect much the result compared to 2n+m, so you need n+m bits to represent the result.

For example 11112*11112 = 111000012 (15*15 = 225)

In general, (bn - 1)*(bm - 1) = bn+m - bn - bm + 1, so multiply an n-digit by an m-digit number in an arbitrary base b results in a number at most n+m digits

You can see that easily in base 10: 9*9 = 81 (1 digit * 1 digit = 2 digit) or 99*99 = 9801 (2 digit * 2 digit = 4 digit)

这篇关于两个16位数字的乘法-为什么结果为32位长?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆