整型数字按位取
来源:互联网 发布:客户管理crm软件 编辑:程序博客网 时间:2024/06/11 08:08
#include "stdafx.h"
#include <windows.h>
void countone2(int N)
{
int a = N;
int count = 0;
int b ;
for (int i=0;i<32;i++)
{
b = (a>>i)&0x01;
printf("%d ",b);
if (1 == b)
{
count ++;
}
}
printf("\n二进制总共有%d个‘1’\n",count);
}
void gethorl()
{
unsigned int test = 255;
unsigned int test_h = (test>>16)&0xffff;
unsigned int test_l = test&0xffff;
printf("%u %u\n",test_l,test_h);
}
void low_high()
{
int a = 250;
byte low8a = (a<<8)>>8;//低8位
byte high8a = a>>8;//高8位
printf("%u %u\n",low8a,high8a);
}
int _tmain(int argc, _TCHAR* argv[])
{
countone2(255);
gethorl();
low_high();
system("pause");
return 0;
}
#include <windows.h>
void countone2(int N)
{
int a = N;
int count = 0;
int b ;
for (int i=0;i<32;i++)
{
b = (a>>i)&0x01;
printf("%d ",b);
if (1 == b)
{
count ++;
}
}
printf("\n二进制总共有%d个‘1’\n",count);
}
void gethorl()
{
unsigned int test = 255;
unsigned int test_h = (test>>16)&0xffff;
unsigned int test_l = test&0xffff;
printf("%u %u\n",test_l,test_h);
}
void low_high()
{
int a = 250;
byte low8a = (a<<8)>>8;//低8位
byte high8a = a>>8;//高8位
printf("%u %u\n",low8a,high8a);
}
int _tmain(int argc, _TCHAR* argv[])
{
countone2(255);
gethorl();
low_high();
system("pause");
return 0;
}
0 0
- 整型数字按位取
- javascript 整型数字 校验
- 字符串转整型数字
- 将字符数字转换为整型数字
- 将整型数组转成一个完整的整型数字
- 转化ip地址为长整型数字
- 求两个整型数字的最大公约数问题
- java判断数字(整型,浮点) 正则表达式
- 字符串转换为整型数字(C#)
- 简单算法--将一个整型数字逆转
- 获取整型数字某一位的值
- 高效实现整型数字转字符串int2str
- 将数字字符串转换为整型
- 整型数字在计算机中的表示
- 去除整型数组中的重复数字
- 华为oj之(整型)数字颠倒
- c++ 字符串数字转整型函数
- JS浮点转整型、数字转字符串
- mac os 10.10 Yosemite 安装
- java 反射简介
- REST service 之登录注册
- linux网络编程之 epoll
- EL表达式中使用三目运算符
- 整型数字按位取
- iOS中系统自带正则表达式的应用以及一些常用的正则表达式
- HTB
- 多模块maven项目实践经验
- SwipeListView的一些实例讲解
- 【Java TCP/IP Socket】Socket编程大合集
- href=#与href=javascriptvoid(0)的区别
- windows embedded compact 2013 VS2012安装教程 最新(2014.7)
- hdu 1203 I NEED A OFFER!