字节换算

bit(b)=位

字节(byte)=8位 -128~127 0~255

半字=2字节=16位 -32768~32767 0~65,535

字(word)=4字节=32位 -2147483848~2147483647 0~4,294,967,295

双字=8字节=64位 -9223372036854775808~9223372036854775807 0~18,446,744,073,709,551,615

十进制-1的二进制表示

在IA-32平台使用补码表示带符号的整数

反码:无符号整数相反代码1->0;0->1。

补码:反码+1

过程

在一个字节中1

二进制是0000 0001

反码 1111 1110

补码 1111 1111 即-1

补码从1111 1111 开始递减直到1000 0000表示-128

一个 16位的1的二进制是

0000 0000 0000 0001

补码即-1是

1111 1111 1111 1111

注意不要把8位的1111 1111即-1和15位的1111 1111 1111 1111即-1混淆!同时16位中1111 1111是255

16位编译器和32位编译器

16位下int 2个字节 long 4个字节 short 2个字节

32位下int4个字节 long 4个字节 short 2个字节

64位下int4个字节 long 8个字节 short 2个字节

printf( "size of \"short\" =%lu\n", sizeof(short));
printf( "size of \"char\" =%lu\n", sizeof(char));
printf( "size of \"long\" =%lu\n", sizeof(long));
printf( "size of \"double\" =%lu\n", sizeof(double));
printf( "size of \"int\" =%lu\n", sizeof(int));
printf( "bit of \"int\" =%lu\n", sizeof(int)*8);
32位和64位下输出比较

各种常数 规则 范例
十进制 一般十进制格式 1234
二进制 以0b开头 0b00111010
八进制 以O开头 O056
十六进制 以开0x头 0x56ab
无正负号整数常数 结尾加上U 300U
长整数常数 结尾加上L 300L
无正负号整数常数 结尾加上UL 300UL
浮点数常数 结尾加上F 4.32F
字符常数 单引号中的文字 ‘a’
字符串常数 双引号中的文字 “hello”

int和Long等的最大最小值MAX和MIN可以参考 limits.h

#whereis limits.h

limits: /usr/include/limits.h

32位下的
limits.h

/**  ISO C99 Standard: 7.10/5.2.4.2.1 Sizes of integer types <limits.h>*/#ifndef _LIBC_LIMITS_H_
#define _LIBC_LIMITS_H_ 1#include <features.h>/* Maximum length of any multibyte character in any locale.We define this value here since the gcc header does not definethe correct value.  */
#define MB_LEN_MAX  16/* If we are not using GNU CC we have to define all the symbols ourself.Otherwise use gcc's definitions (see below).  */
#if !defined __GNUC__ || __GNUC__ < 2/* We only protect from multiple inclusion here, because all the other#include's protect themselves, and in GCC 2 we may #include_next throughmultiple copies of this file before we get to GCC's.  */
# ifndef _LIMITS_H
#  define _LIMITS_H 1#include <bits/wordsize.h>/* We don't have #include_next.Define ANSI <limits.h> for standard 32-bit words.  *//* These assume 8-bit `char's, 16-bit `short int's,and 32-bit `int's and `long int's.  *//* Number of bits in a `char'.   */
#  define CHAR_BIT  8/* Minimum and maximum values a `signed char' can hold.  */
#  define SCHAR_MIN (-128)
#  define SCHAR_MAX 127/* Maximum value an `unsigned char' can hold.  (Minimum is 0.)  */
#  define UCHAR_MAX 255/* Minimum and maximum values a `char' can hold.  */
#  ifdef __CHAR_UNSIGNED__
#   define CHAR_MIN 0
#   define CHAR_MAX UCHAR_MAX
#  else
#   define CHAR_MIN SCHAR_MIN
#   define CHAR_MAX SCHAR_MAX
#  endif/* Minimum and maximum values a `signed short int' can hold.  */
#  define SHRT_MIN  (-32768)
#  define SHRT_MAX  32767/* Maximum value an `unsigned short int' can hold.  (Minimum is 0.)  */
#  define USHRT_MAX 65535/* Minimum and maximum values a `signed int' can hold.  */
#  define INT_MIN   (-INT_MAX - 1)
#  define INT_MAX   2147483647/* Maximum value an `unsigned int' can hold.  (Minimum is 0.)  */
#  define UINT_MAX  4294967295U/* Minimum and maximum values a `signed long int' can hold.  */
#  if __WORDSIZE == 64
#   define LONG_MAX 9223372036854775807L
#  else
#   define LONG_MAX 2147483647L
#  endif
#  define LONG_MIN  (-LONG_MAX - 1L)/* Maximum value an `unsigned long int' can hold.  (Minimum is 0.)  */
#  if __WORDSIZE == 64
#   define ULONG_MAX    18446744073709551615UL
#  else
#   define ULONG_MAX    4294967295UL
#  endif#  ifdef __USE_ISOC99/* Minimum and maximum values a `signed long long int' can hold.  */
#   define LLONG_MAX    9223372036854775807LL
#   define LLONG_MIN    (-LLONG_MAX - 1LL)/* Maximum value an `unsigned long long int' can hold.  (Minimum is 0.)  */
#   define ULLONG_MAX   18446744073709551615ULL#  endif /* ISO C99 */# endif    /* limits.h  */
#endif  /* GCC 2.  */#endif /* !_LIBC_LIMITS_H_ *//* Get the compiler's limits.h, which defines almost all the ISO constants.We put this #include_next outside the double inclusion check becauseit should be possible to include this file more than once and still getthe definitions from gcc's header.  */
#if defined __GNUC__ && !defined _GCC_LIMITS_H_
/* `_GCC_LIMITS_H_' is what GCC's file defines.  */
# include_next <limits.h>
#endif/* The <limits.h> files in some gcc versions don't define LLONG_MIN,LLONG_MAX, and ULLONG_MAX.  Instead only the values gcc defined forages are available.  */
#if defined __USE_ISOC99 && defined __GNUC__
# ifndef LLONG_MIN
#  define LLONG_MIN (-LLONG_MAX-1)
# endif
# ifndef LLONG_MAX
#  define LLONG_MAX __LONG_LONG_MAX__
# endif
# ifndef ULLONG_MAX
#  define ULLONG_MAX    (LLONG_MAX * 2ULL + 1)
# endif
#endif#ifdef    __USE_POSIX
/* POSIX adds things to <limits.h>.  */
# include <bits/posix1_lim.h>
#endif#ifdef    __USE_POSIX2
# include <bits/posix2_lim.h>
#endif#ifdef    __USE_XOPEN
# include <bits/xopen_lim.h>
#endif

64位下的
limits.h

/**  ISO C99 Standard: 7.10/5.2.4.2.1 Sizes of integer types <limits.h>*/#ifndef _LIBC_LIMITS_H_
#define _LIBC_LIMITS_H_ 1#include <features.h>/* Maximum length of any multibyte character in any locale.We define this value here since the gcc header does not definethe correct value.  */
#define MB_LEN_MAX  16/* If we are not using GNU CC we have to define all the symbols ourself.Otherwise use gcc's definitions (see below).  */
#if !defined __GNUC__ || __GNUC__ < 2/* We only protect from multiple inclusion here, because all the other#include's protect themselves, and in GCC 2 we may #include_next throughmultiple copies of this file before we get to GCC's.  */
# ifndef _LIMITS_H
#  define _LIMITS_H 1#include <bits/wordsize.h>/* We don't have #include_next.Define ANSI <limits.h> for standard 32-bit words.  *//* These assume 8-bit `char's, 16-bit `short int's,and 32-bit `int's and `long int's.  *//* Number of bits in a `char'.   */
#  define CHAR_BIT  8/* Minimum and maximum values a `signed char' can hold.  */
#  define SCHAR_MIN (-128)
#  define SCHAR_MAX 127/* Maximum value an `unsigned char' can hold.  (Minimum is 0.)  */
#  define UCHAR_MAX 255/* Minimum and maximum values a `char' can hold.  */
#  ifdef __CHAR_UNSIGNED__
#   define CHAR_MIN 0
#   define CHAR_MAX UCHAR_MAX
#  else
#   define CHAR_MIN SCHAR_MIN
#   define CHAR_MAX SCHAR_MAX
#  endif/* Minimum and maximum values a `signed short int' can hold.  */
#  define SHRT_MIN  (-32768)
#  define SHRT_MAX  32767/* Maximum value an `unsigned short int' can hold.  (Minimum is 0.)  */
#  define USHRT_MAX 65535/* Minimum and maximum values a `signed int' can hold.  */
#  define INT_MIN   (-INT_MAX - 1)
#  define INT_MAX   2147483647/* Maximum value an `unsigned int' can hold.  (Minimum is 0.)  */
#  define UINT_MAX  4294967295U/* Minimum and maximum values a `signed long int' can hold.  */
#  if __WORDSIZE == 64
#   define LONG_MAX 9223372036854775807L
#  else
#   define LONG_MAX 2147483647L
#  endif
#  define LONG_MIN  (-LONG_MAX - 1L)/* Maximum value an `unsigned long int' can hold.  (Minimum is 0.)  */
#  if __WORDSIZE == 64
#   define ULONG_MAX    18446744073709551615UL
#  else
#   define ULONG_MAX    4294967295UL
#  endif#  ifdef __USE_ISOC99/* Minimum and maximum values a `signed long long int' can hold.  */
#   define LLONG_MAX    9223372036854775807LL
#   define LLONG_MIN    (-LLONG_MAX - 1LL)/* Maximum value an `unsigned long long int' can hold.  (Minimum is 0.)  */
#   define ULLONG_MAX   18446744073709551615ULL#  endif /* ISO C99 */# endif    /* limits.h  */
#endif  /* GCC 2.  */#endif /* !_LIBC_LIMITS_H_ *//* Get the compiler's limits.h, which defines almost all the ISO constants.We put this #include_next outside the double inclusion check becauseit should be possible to include this file more than once and still getthe definitions from gcc's header.  */
#if defined __GNUC__ && !defined _GCC_LIMITS_H_
/* `_GCC_LIMITS_H_' is what GCC's file defines.  */
# include_next <limits.h>
#endif/* The <limits.h> files in some gcc versions don't define LLONG_MIN,LLONG_MAX, and ULLONG_MAX.  Instead only the values gcc defined forages are available.  */
#if defined __USE_ISOC99 && defined __GNUC__
# ifndef LLONG_MIN
#  define LLONG_MIN (-LLONG_MAX-1)
# endif
# ifndef LLONG_MAX
#  define LLONG_MAX __LONG_LONG_MAX__
# endif
# ifndef ULLONG_MAX
#  define ULLONG_MAX    (LLONG_MAX * 2ULL + 1)
# endif
#endif#ifdef    __USE_POSIX
/* POSIX adds things to <limits.h>.  */
# include <bits/posix1_lim.h>
#endif#ifdef    __USE_POSIX2
# include <bits/posix2_lim.h>
#endif#ifdef    __USE_XOPEN
# include <bits/xopen_lim.h>
#endif

从1的补码说起计算机的数制相关推荐

  1. 计算机组成原理补码加法证明,补码加减法运算(计算机组成原理).ppt

    <补码加减法运算(计算机组成原理).ppt>由会员分享,可在线阅读,更多相关<补码加减法运算(计算机组成原理).ppt(25页珍藏版)>请在皮匠网上搜索. 1.计算机组成原理2 ...

  2. 计算机数制转换操作方法,计算机基础 数制及其相互转换

    <计算机基础 数制及其相互转换>由会员分享,可在线阅读,更多相关<计算机基础 数制及其相互转换(39页珍藏版)>请在人人文库网上搜索. 1.领域一 项目13 游戏二进制,教学目 ...

  3. 计算机进位制转换方法,计算机进位数制及其转换方法和技巧

    计算机进位数制及其转换方法和技巧 计算机进位数制及其转换方法和技巧 李军豪 邱红丽 (河南质量工程职业学院) 摘要计算机数制间的转换途径有多种,在应用时一定要灵活.根据实践教学经验,主要分析了教学中有 ...

  4. 计算机进位制转换方法,计算机进位数制及其转换方法和技巧.doc

    文档介绍: 二进制及几种进位数制的转换问题.每当学生遇到这部分内容时,总是感到很茫然.在计算机中为什么使用二进制数编码,通过开始菜单"附件"中的"计算器"功能可 ...

  5. 计算机二进制转化教案及ppt,计算机《数制与编码-进制转换》公开课教案.doc

    文档介绍: 计算机<数制与编码-进制转换>公开课教案数制与编码--进制转换[学情分析]本课内容是在学生已经学****了计算机发展与应用.计算机系统的组成等知识的基础上进行,已经初步知道了人 ...

  6. 计算机进制换算方法 ppt,计算机基础数制及其相互转换.ppt

    <计算机基础数制及其相互转换.ppt>由会员分享,可在线阅读,更多相关<计算机基础数制及其相互转换.ppt(39页珍藏版)>请在人人文库网上搜索. 1.领域一 项目13 游戏二 ...

  7. 计算机基础数制转换教学ppt,计算机基础-数制及其相互转换PPT课件

    <计算机基础-数制及其相互转换PPT课件>由会员分享,可在线阅读,更多相关<计算机基础-数制及其相互转换PPT课件(39页珍藏版)>请在人人文库网上搜索. 1.1 1 2 2 ...

  8. 计算机中常用数制及编码教案,计算机《数制与编码-进制转换》公开课教案

    <计算机<数制与编码-进制转换>公开课教案>由会员分享,可在线阅读,更多相关<计算机<数制与编码-进制转换>公开课教案(8页珍藏版)>请在人人文库网上搜 ...

  9. 补码乘法运算(计算机组成原理18)

    补码乘法运算 视频链接地址: https://www.bilibili.com/video/BV1BE411D7ii?from=search&seid=6420326887479343502 ...

最新文章

  1. BlueTooth 蓝牙音频音质探讨
  2. Linux进阶之路————开机、重启和用户登录注销
  3. 上新啦!OpenMMLab全面更新!
  4. Python中文件的读写、写读和追加写读三种模式的特点
  5. python中args是什么意思_理解Python中的*,*args
  6. 修改10g自动统计信息收集作业GATHER_STATS_JOB到仅仅周末执行
  7. MLP、RBF、SVM网络比较及其应用前景
  8. 只要是[运算] 就会提升数据类型
  9. rocketmq消息积压
  10. 【原创】ES5高效封装WIN10系统教程2020系列(一)母盘定制
  11. Cesium-相机系统与视域移动
  12. Golang中defer、return、返回值之间执行顺序的坑
  13. windows删除文件时需要管理员权限的方法
  14. 手把手交给大家怎样破解压缩包密码的方法
  15. 微信公众号发红包 php,php微信公众号接口实现发红包的方法
  16. java设置pdf不可编辑_Java动态生成pdf文件(使用itext编辑pdf)
  17. 鹏业安装算量软件V8.0.0 Build 60(及58)升级内容
  18. 学python要有多少英语词汇量_学习英语到底多少词汇量够用,1年能学习到1000的词汇量吗?...
  19. 支持javascript的ppt软件_Reveal.js是在浏览器中播放创建在线PPT幻灯片的开源库包...
  20. 第四章 Python组合数据类型

热门文章

  1. 使用NetworkX绘制深度神经网络结构图(Python)
  2. poj 2449 Remmarguts' Date 启发式搜索 A*算法
  3. 【深度学习】(1) 前向传播,附python完整代码
  4. 【TensorFlow2.0】(6) 数据统计,范数、最值、求和、均值、最值位置、唯一值、张量比较
  5. Linux 进程及进程之间的通信机制——管道
  6. 数字图像处理——第九章 形态学图像处理
  7. LeetCode刷题记录14——257. Binary Tree Paths(easy)
  8. 三维点云语义分割总览
  9. ATS 6.2.1中缓存文件过期并不回源校验的“坑”
  10. 虚幻引擎5(UE5)实时VFX游戏特效制作入门到精通