基于二进制运算的整数加法伪码算法 [英] A pseudocode algorithm for integer addition based on binary operation

查看:122
本文介绍了基于二进制运算的整数加法伪码算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很久以来一直想出一个解决方案,但无法解决这个问题。

I have tried for ages to come up with a solution but just can't get my head around it.

它必须基于两个整数使用具有直接硬件实现和,或,异或的非标准逻辑运算

It needs to be based on two integers on the use of standard logical operations which have direct hardware implementation AND, OR, XOR, NOT

这对我帮助我将要开始的项目提供了指导可以解释一下。

It's a guidance for me to help with my project I am going to start, if anyone can explain it please.

我要用Python

推荐答案

基本组件是完整加法器。它具有3个输入(有点来自 a ,有点来自 b 和进位)和两个输出(有点求和)。其功能为

The basic component is a full adder. It has 3 inputs (a bit from a, a bit from b and carry) and two outputs (a bit of sum and carry). Its functionality is

    out = a ^ b ^ carry
    carry = a & b | (carry & (a^b))

最初的进位为0。位从最低有效位开始。

Initially carry is 0. Apply the statements above to each bit starting from the least significant one.

这篇关于基于二进制运算的整数加法伪码算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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