Download presentation

Presentation is loading. Please wait.

Published byJaquan Glaspell Modified over 2 years ago

1
Bits and Bytes And why we have to care in VB!

2
All computer storage is organized into bytes Think of each byte as a little storage bin Each byte is made up of 8 bits Each bit is an electronic circuit that is either on or off (off = 0, on = 1) A specific sequence of 0s and 1s in a byte is called a bit pattern

3
What kinds of information do you store on your computer? numerical values (binary number system) text/character data (ASCII or Unicode) program instructions (machine language) images (jpg, gif, tiff, bmp, wmf, etc.) video (mp4, mov, avi, wmv, etc.) music (mp3, wav, wma, au, etc.)

4
Numerical Values vs Strings (text/characters) 40 Oak St $40

5
40 Oak St is a string 00110100 00110000 00100000 01001111 01100001 01101011 00100000 01010011 01110100 It would be stored like this using ASCII codesASCII codes

6
The 40 in $40 needs to be a numerical value for arithmetic The numerical value 40 would be stored like this using the binary number system. 00101000

7
Compare: 40 vs 40 00110100 00110000 The text string 40 The numerical value 40 00101000

8
How do binary numbers work? Decimal Number SystemBinary Number System Base 10Base 2 10 digits (0,1,2,3,4,5,6,7,8,9)2 digits (0,1) Positional values based on powers of 10Positional values based on powers of 2 Positional Values 1286432168421 2727 2626 2525 2424 23232 2121 2020 Binary Number 8-bit binary number

9
Converting from Binary to Decimal Positional Values 1286432168421 2727 2626 2525 2424 23232 2121 2020 Binary Number 01101010 What is the decimal value of the bit pattern 01101010 ? Simple! Just add up the positional values where the 1s appear: 64 + 32 + 8 + 2 = 106 So, we say that 01101010 2 = 106 decimal

10
Converting from Decimal to Binary Positional Values 1286432168421 2727 2626 2525 2424 23232 2121 2020 Binary Number How can we represent the decimal value 151 in binary? Simple! Just think about money and consider positional values as coins and 151 cents as the change we must make. Then count change from largest denomination to smallest until total value of change is accumulated.

11
Converting from Decimal to Binary Positional Values 1286432168421 2727 2626 2525 2424 23232 2121 2020 Binary Number 1 How can we represent the decimal value 151 in binary? Running Total: 128

12
Converting from Decimal to Binary Positional Values 1286432168421 2727 2626 2525 2424 23232 2121 2020 Binary Number 10 How can we represent the decimal value 151 in binary? Running Total: 128

13
Converting from Decimal to Binary Positional Values 1286432168421 2727 2626 2525 2424 23232 2121 2020 Binary Number 100 How can we represent the decimal value 151 in binary? Running Total: 128

14
Converting from Decimal to Binary Positional Values 1286432168421 2727 2626 2525 2424 23232 2121 2020 Binary Number 1001 How can we represent the decimal value 151 in binary? Running Total: 128 + 16 = 144

15
Converting from Decimal to Binary Positional Values 1286432168421 2727 2626 2525 2424 23232 2121 2020 Binary Number 10010 How can we represent the decimal value 151 in binary? Running Total: 128 + 16 = 144

16
Converting from Decimal to Binary Positional Values 1286432168421 2727 2626 2525 2424 23232 2121 2020 Binary Number 100101 How can we represent the decimal value 151 in binary? Running Total: 128 + 16 + 4 = 148

17
Converting from Decimal to Binary Positional Values 1286432168421 2727 2626 2525 2424 23232 2121 2020 Binary Number 1001011 How can we represent the decimal value 151 in binary? Running Total: 128 + 16 + 4 + 2 = 150

18
Converting from Decimal to Binary Positional Values 1286432168421 2727 2626 2525 2424 23232 2121 2020 Binary Number 10010111 How can we represent the decimal value 151 in binary? Running Total: 128 + 16 + 4 + 2 + 1 = 151 So, 151 decimal = 10010111 2

19
Compare: 40 vs 40 00110100 00110000 The text string 40 The numerical value 40 00101000

20
Consider GPA Program Input? Output?

21
Consider GPA Program Input Output

22
Bottom Line All input values provided via text boxes on VB forms are stored as text All output values provided placed in labels on VB forms are stored as text To use values in computations for processing in VB, the values must be numeric HOWEVER

23
Beginning of GPA Program On Screen Behind the Scenes in Memory (RAM) credithrsTxt qualptsTxt gpaLbl credithrs qualpts gpa Note: credithrs, qualpts, and gpa are called variables

24
Input Phase GPA Program On ScreenBehind the Scenes in Memory (RAM) credithrsTxt qualptsTxt gpaLbl credithrs qualpts gpa

25
Input Phase GPA Program On ScreenBehind the Scenes in Memory (RAM) credithrsTxt qualptsTxt gpaLbl credithrs qualpts gpa

26
Input Phase GPA Program On ScreenBehind the Scenes in Memory (RAM) 00101000 credithrsTxt qualptsTxt gpaLbl credithrs qualpts gpa

27
Input Phase GPA Program On ScreenBehind the Scenes in Memory (RAM) 00101000 credithrsTxt qualptsTxt gpaLbl credithrs qualpts gpa

28
Input Phase GPA Program On ScreenBehind the Scenes In memory (RAM) 00101000 10100000 credithrsTxt qualptsTxt gpaLbl credithrs qualpts gpa

29
Processing Phase GPA Program On ScreenBehind the Scenes in Memory (RAM) 00101000 10100000 credithrsTxt qualptsTxt gpaLbl credithrs qualpts gpa

30
Processing Phase GPA Program On ScreenBehind the Scenes in Memory (RAM) 00101000 10100000 00000100 credithrsTxt qualptsTxt gpaLbl credithrs qualpts gpa

31
Output Phase GPA Program On ScreenBehind the Scenes in Memory (RAM) 00101000 10100000 00000100 credithrsTxt qualptsTxt gpaLbl credithrs qualpts gpa

32
Output Phase GPA Program On ScreenBehind the Scenes in Memory (RAM) 00101000 10100000 00000100 credithrsTxt qualptsTxt gpaLbl credithrs qualpts gpa

33
Good News is … We dont have to directly handle the nitty- gritty details of converting text to binary for input We dont have to directly handle the nitty- gritty details details of converting binary to text for output Phew!

34
Not So Good News is … We do have to explicitly ask VB to do the conversions when necessary

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google