Section 2:Computer Memory and Number Systems

文章目录

  • Section 2:Computer Memory and Number Systems
    • The flipflop
    • Number Systems
    • The Decimal number system
    • The Binary number system
    • Carry 1 in binary
    • Bits and Bytes
    • An interesting thought
    • Converting binary to decimal
    • Converting decimal to binary
    • The Hexadecimal number system
    • Converting hexadecimal to decimal
    • Converting decimal to hexadecimal
    • Converting binary to hexadecimal (IMPORTANT)
    • The Octal number system(this has NOTHING to do with our course)
    • How a computer represents negative integers
    • Method 1: Sign and Magnitude
    • Method 2: Ones Complement
    • Method 3: Twos Complement
    • Definitions –you need to know these
    • Largest integer in a computer
    • Program to check the size of a variable
    • maxint (IMPORTANTfor all programmers)

  This section looks at how computer memory is constructed from circuits and how computers store integer values in memory. People usually work in the decimal number system but computers work in binary. Hexadecimal is used as a shorthand for writing binary.

The flipflop

  The flipflop is a circuit with 2 inputs and 1 output. It is an independent circuit (it does not require continuous input) and it is a bistable circuit (it has 2 states). We could study the circuit required to construct a flipflop but we will not do that.

Number Systems

  Any number system has a base and a set of digits to represent the number. The digits are arranged in columns where each column represents a different power of the base.Number systems have been used for thousands of years –they have nothing to do with computers.

The Decimal number system

  Let us start off by studying the decimal number system.For thousands of years, humans have used the decimal number system for counting. It is convenient to use the decimal number system because we have ten fingers. This is why the English word ‘digit’ means a number symbol and also means a finger (or a toe). However, not all societies have used the decimal number system. For instance, in about 3000BC, the Babylonians used the number system with base 60. And that is why we have 60 seconds in a minute and 60 minutes in an hour.

Important definitions:

The Binary number system

  The binary number system collects numbers into groups of 2. The baseof the binary number system is 2. The digits of the binary number system are 0 to 1. To represent any number we write down how many groups we have of each power of 2.


Carry 1 in binary

Bits and Bytes

An interesting thought

  An interesting exercise is to calculate what is the maximum value that can be stored in a specified number of bits. Easy to do, just assume every flipflop is ON (i.e. assume every bit is 1).
  E.g. maximum value you can store in 4 bits is: 1111 = 15 (Fun fact: 4 bits is called a nibble).
  As computers increased in power, they were able to include thousands of bytes in the memory.210(1024) bytes is called a kilobyte(written as KB). It is sometimes assumed that a kilobyte is1000 bytesif precision is not required.A megabyte is 1,000,000 bytes, etc.

Converting binary to decimal

Converting decimal to binary

The Hexadecimal number system


Converting hexadecimal to decimal

Converting decimal to hexadecimal

Converting binary to hexadecimal (IMPORTANT)

 It is very easy to convert binary to hexadecimal by looking at groups of 4 binary digits:
 For example, convert the binary number 1001102to hexadecimal.
Put the binary into groups of four(place extra zeros at the front if needed).
 Thus 100110 becomes 0010 0110
Now write the single corresponding hexadecimal digit for each group of four.
 So 1001102becomes 2616
We use hexadecimal as a shorthand for writing binary.

The Octal number system(this has NOTHING to do with our course)

How a computer represents negative integers

 Computers have a fixed word size. This is the number of bits that are available to store one integer value. For example, in a computer with a word size of 8, there will be 8 bits used to store one binary number. So the number 5 (in such a computer) will be stored as: 0000 0101
 In a computer with a word size of 16, the number 5 will be stored as: 0000 0000 0000 0101We need to represent negative numbers and we use the fact that computers have a fixed word size.

Method 1: Sign and Magnitude

The most significant bit(at the left hand side of the number) becomes the sign bit.
The most significant bit = 0 for a positive number and 1 for a negative number.

Method 2: Ones Complement

Method 3: Twos Complement

 Complement thenumber and add 1.

Definitions –you need to know these

Largest integer in a computer


Program to check the size of a variable

maxint (IMPORTANTfor all programmers)

 maxintis the largest integer value that can be stored in a computer. The size of maxint will differ, depending on the variable used (e.g. long) and the make of computer BUT there is always a maxint. It is very important for programmers to know about maxint. In other words, you must know that there is a particular integer value that if you add 1 (or greater) to it, you will get a meaningless answer. Many programmers create programs without realising that they may set up a series of calculations that could produce a meaningless result(if the final result is greater than maxint).

C++ 从入门到入土(English Version) Section 2:Computer Memory and Number Systems相关推荐

  1. spring 依赖注入_Spring从入门到入土——依赖注入(DI)

    Dependency Injection 概念 依赖注入(DI) 依赖:指Bean对象的创建依赖于容器.Bean对象的依赖资源 注入:指Bean对象 注入方式 一共有三种:分别是构造器注入:Set注入 ...

  2. Flink 教程 gitbook 从入门到入土(详细教程)

    Flink从入门到入土(详细教程) 和其他所有的计算框架一样,flink也有一些基础的开发步骤以及基础,核心的API,从开发步骤的角度来讲,主要分为四大部分 1.Environment Flink J ...

  3. Ajax!从入门到入土

    Ajax!从入门到入土 Ajax 1.JSON 1.1 什么是JSON 1.2 JSON语法 2.JSON的解析 2.1 Java中解析JSON 2.1.1 FastJSON解析 2.1.2 Jack ...

  4. 决战Go语言从入门到入土v0.1

    下载地址:https://gitcode.net/as604049322/blog_pdf 安装与运行环境 Go 语言环境安装 Go语言支持Linux.Mac和Windows,本人接下来的学习全部基于 ...

  5. Mermaid从入门到入土

    概述 What Mermaid是基于Javascript的绘图工具,用户可以方便快捷地通过代码创建图表 项目地址:mermaid How 特定的Mermaid渲染器:mermaid-live-edit ...

  6. rocketmq怎么保证消息一致性_从入门到入土(三)RocketMQ 怎么保证的消息不丢失?...

    精彩推荐 一百期Java面试题汇总SpringBoot内容聚合IntelliJ IDEA内容聚合Mybatis内容聚合 接上一篇:RocketMQ入门到入土(二)事务消息&顺序消息 面试官常常 ...

  7. Activiti工作流从入门到入土:完整Hello World大比拼(Activiti工作流 API结合实例讲解)

    文章源码托管:https://github.com/OUYANGSIHAI/Activiti-learninig 欢迎 star !!! 本来想着闲来无事,前面在项目中刚刚用到了工作流 Activit ...

  8. activiti api文档_【白银人机】Activiti 工作流从入门到入土:完整 hello world 大比拼(API 结合实例讲解)...

    点击上方"好好学java",选择"置顶"公众号 重磅资源.干货,第一时间送达 重磅推荐  ① 纯福利 | 公众号资源大汇总,一年才一次! ② 重磅!!2018年 ...

  9. 从入门到入土(十)RocketMQ集群流程以及核心概念

    精彩推荐 一百期Java面试题汇总 SpringBoot内容聚合 IntelliJ IDEA内容聚合 Mybatis内容聚合 接上一篇:从入门到入土(九)手摸手教你搭建RocketMQ双主双从同步集群 ...

  10. 从入门到入土(九)手摸手教你搭建RocketMQ双主双从同步集群,不信学不会!...

    精彩推荐 一百期Java面试题汇总 SpringBoot内容聚合 IntelliJ IDEA内容聚合 Mybatis内容聚合 接上一篇:从入门到入土(八)RocketMQ的Consumer是如何做的负 ...

最新文章

  1. Xshell5中常用linux服务器命令集合
  2. Java 8中的时间日期库DateTime API及示例
  3. Android移动开发之【通往安卓的神奇之旅】基于回调的事件处理
  4. Windows 公共控件库研究
  5. [Ajax] jQuery中的Ajax -- 02-jQuery中的三级联动
  6. 11月百度凤巢升级后的变化
  7. 加载本地文件为String类型
  8. 山山的数学(简单版)
  9. LINUX编译OpenJDK8:cc1plus: all warnings being treated as errors
  10. ssh服务器安装测试
  11. oppo a57刷机成功教程
  12. JavaScript高级程序设计[美]Nicholas C.Zakas著 读书笔记(三)
  13. (五)什么是软件架构视图 4+1视图
  14. Swift 读标准库源码笔记 -- Integers(基本数据类型篇)
  15. android坐标计算器,函数科学计算器算坐标
  16. IEC61850笔记--开源代码libIEC61850(一)
  17. 2022年流动式起重机司机考试题库模拟考试平台操作
  18. 不良征信大盘点 这13种情况一定不要犯!
  19. 一个屌丝程序员的青春(一零五)
  20. 大新闻!微软正考虑添加 Python 为官方的 Excel 脚本语言

热门文章

  1. TSNE—聚类结果可视化
  2. 统计学习方法读书笔记4-感知机课后习题
  3. mysql基础7-MYSQL连接查询
  4. RabbitMQ学习——常见概念详解
  5. 不会Netty,你也永远不会熟悉Java
  6. windows系统文件和dll文件
  7. PHP什么函数获取日期,php getdate()函数获取日期信息实例详解
  8. pom文件报错_FastDFS实战总结,分布式文件存储,高并发高可用,看这篇就够了...
  9. 网和aoe网的区别_【专定网】你知道到亚克力鱼缸与超白缸的区别吗?测评结果给你答案...
  10. appscan无法连接到服务器_和平精英无法连接到服务器是怎么回事 最新解决方案...