Mutual Convert between decimal and binary integer

Decimal binary transfer:
Divided by 2 was removed from the results of a
The remainder and the last one written from the bottom up is the result of such reverse 302
302 / 2 = 151 I 0
151 / 2 = 75 I 1
75 / 2 = 37 I 1
37 / 2 = 18 I 1
18 / 2 = 9 I 0
9 / 2 = 4 I 1
4 / 2 = 2 I 0
2 / 2 = 1 I 0
Therefore, the binary is 100 101 110

Decimal binary switch:
Starting from the last count, in turn classified as 0,1,2 ... place the first n-bit number (0 or 1) multiplied by 2 n-th power sum of the results obtained is the answer for example: 01101011. Turn metric :
Bit 0: 1 x 2 = 1 0 th power
1 x 2 1 th power = 2
0 x 2 2 power = 0
1 x 2 3 power = 8
0 x 2 4 th power = 0
1 x 2 5 th power = 32
1 by 2 ^ 6 = 64
0 x 2 7 th power = 0
Then: 1 +2 +0
+32 +64 +8 +0 +0 = 107.
Binary 01101011 = decimal 107.

分类:Tech 时间:2010-08-13 人气:259
分享到:
blog comments powered by Disqus

相关文章

  • To determine whether a power of 2 number of techniques 2010-12-16

    To determine the number set is an unsigned integer X. First, to determine whether X is 0, if n 0 is not a power of 2, to return. X and X-1 carried by bit with the operation, if the result is 0, then this number is 2 n-th power; if the result is not 0

  • N! behind the number 0 (classical turn) 2010-12-01

    public static int countFactorialZero (int n) {/ / timeout int ret = 0; / / Note: the first cycle that a multiple of 5 ^ 1, each contributing a 5 / / The second time that a multiple of 5 ^ 2, will also contribute an extra 5 //... An analogy while (n!

  • Judgement is not an integer power of 2, the order of the number of 2010-10-01

    8,64,256 power are the order of the number 2 (for example, is 2 3 8 power), to determine with java programming is not an integer power of 2, the order number and indicate which method is better. return n == 0? false: (n-1) & n == 0; Start with 3 per

  • Intel ® architecture the CPU power consumption 2010-08-18

    Introduction High clock rate and sleep disruption to affect Intel's dual-core mobile platform. Study: Karthik Krishnan Win32 * interface provides various API, used to implement the required frequency of application code on a regular basis. Them to th

  • Power over Ethernet - Understanding PoE Technol... - 少即是多 - 专注 2012-06-05

    PoE was invented by PowerDsine back in 1997 and the first power injector ( Midspan) was installed in 1998. Many manufacturespartnered with PowerDsine to make useof this innovation. The Institute ofElectrical and Electronic Engineers (IEEE)was approac

  • Siemens SITOP power to sell discounted stock 2010-04-27

    Special Stock Siemens SITOP Power Contact: Wang Gong TEL :027-50654190 15902710377 FAX :027-50701605 QQ: 1272725679 E-MAIL: wanghaodao@163.com SIEMENS (Siemens) SITOP power 6EP1331-2BA10 Input: 120/230 V AC Output: 24 V DC / 2 A DC 6EP1331-2BA10 Inpu

  • Special stock sell-off of Siemens Power SITOP 2010-04-27

    Special Stock Siemens SITOP Power Contact: Wang Gong TEL :027-50654190 15902710377 FAX :027-50701605 QQ: 1272725679 E-MAIL: wanghaodao@163.com SIEMENS (Siemens) SITOP power 6EP1331-2BA10 Input: 120/230 V AC Output: 24 V DC / 2 A DC 6EP1331-2BA10 Inpu

  • Access using a power of 2 multi-position method of selection box 2010-11-14

    There are more than six box: Box 1 Box 2 Box 3 Box 4 Box 5 Box 6 How to access a value to know that a few select box, that is, to know which box is checked several Each box can code (123456) is its power as the number of: 248,163,264 Just submit dete

  • Computer automatic power 2011-09-15

    The following report from the computer and, if infringement, please inform! 1 boot into bios settings; (2) find the power management settings options (power management features), will "restore on ac power loss" is set to "power on", th

  • android 添加按(power键)电源键结束通话(挂断电话) 2014-02-23

    首先我们发现现在我们所用的android智能手机大部分都有当你在打电话时按power键来挂断电话,一般都是在设置中 首先我们发现现在我们所用的android智能手机大部分都有当你在打电话时按power键来挂断电话,一般都是在设置中. 我主要是在原生源码中添加这一功能,主要用于学习....先看一张图: 看到那个按电源键挂断电话吧,那就是我所添加的,本来原生源码中是没有这一栏的..... 大概思路: 首先我先添加这一个checkboxPreference,然后将是否选择这一功能的值(0和1)存到da

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.197 (s). 12 q(s)