需要的位 [英] bits required

查看:33
本文介绍了需要的位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

计算在交换值a和b时需要更改的位

解决方案

ra ****** @ gmail.com 说:


计算需要的位数交换价值时更改a和b



为什么?


-

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:rjh在上述域名中, - www。


ra ****** @ gmail.com 写道:


计算交换时需要更改的位数价值a和b



你可以重新发布所有你想要的东西,我们仍然不会为你做功课。

你。 />

回到当天,当我还是一名助教(物理学)时,我曾经告诉学生们,b $ b。这是没有意义的。家庭作业。家庭作业对你来说是
。我们只对它进行收集和评分,这样你就可以得到关于你错误地做什么的反馈,并激励你真正开展工作。

考试是我们在哪里找到你真正知道的东西。



Brian


文章< 11 ** ********************@a26g2000pre.googlegroups .com> ;,

< ra ****** @ gmail.comwrote:


>计算在交换值a和b
时需要更改的位数



答案可能不明确的。如果使用临时值,

需要更改的位数设置为临时特定值的b / b $ b将取决于
中的内容
临时开始,如果临时

是自动存储,则不知道。


还有如何计算的问题比特的改变。

如果一个特定的位被改变了两次,那么就是2

(两次改动),或者一次计数(一位改变) )?


是否需要提出一个公式来表示需要更改为交换两个值的位数?
位数?或者

要求提出一个程序来计算

位需要改变以交换两个输入值?

或者是提前给出的两个值?


我们对两个值a和b的类型有什么了解?

它们是整数类型?它们是否可能浮点数b $ b b?它们是否可能是混合类型,一个整体

和一个浮点?


我们如何处理位问题?是一个问题

的代表(在C中没有完全定义),

而value是独立的代表?例如,

如果C实现发生,答案可能会有所不同

使用两个'的补码来代表程序员的价值

正在期待一个人的补充表示。

-

编程是在你忙于制定其他计划时发生的事情。


count the bits required to be altered while swaping values a and b

解决方案

ra******@gmail.com said:

count the bits required to be altered while swaping values a and b

Why?

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.


ra******@gmail.com wrote:

count the bits required to be altered while swaping values a and b


You can repost it all you want, we still won''t do your homework for
you.

Back in the day, when I was a teaching assistant (Physics), I used to
tell the students, "It''s pointless to cheat on homework. Homework is
for you. We only collect and grade it so you''ll get feedback on what
you''re doing wrong and to give you incentive to actually do the work.
Exams are where we find out what you really know."


Brian


In article <11**********************@a26g2000pre.googlegroups .com>,
<ra******@gmail.comwrote:

>count the bits required to be altered while swaping values a and b

The answer may be ill-defined. If a temporary value is used,
the the number of bits required to be altered to set that
temporary to a certain value would depend on what was in
the temporary to start with, which is unknown if the temporary
is in automatic storage.

There is also the question of how to count the alteration of bits.
If a particular bit gets altered twice, then is that a count of 2
(two alterations), or a count of 1 (one bit altered) ?

Is the requirement to come up with a formula that expresses the
number of bits required to be altered to swap two values? Or is
the requirement to come up with a program that would count the
bits required to be altered to swap two values that are inputs?
Or are the two values given ahead of time?

What do we know about the types of the two values a and b?
Are they integral types? Are they potentially floating point
numbers? Are they potentially of mixed type, one integral
and one floating point?

What are we to do about the problem that "bits" are a matter
of representation (which is not completely defined in C),
whereas "values" are independant of representation? For example,
the answer might be different if the C implementation happens
to be using two''s complement to represent values when the programmer
is expecting one''s complement representation instead.
--
Programming is what happens while you''re busy making other plans.


这篇关于需要的位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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