Download presentation
Presentation is loading. Please wait.
1
Data Types
2
DISCLAIMER & USAGE The content of this presentation is for informational purposes only and is intended for students attending Louisiana Tech University only. The authors of this information do not make any claims as to the validity or accuracy of the information or methods presented. Any procedures demonstrated here are potentially dangerous and could result in damage and injury. Louisiana Tech University, its officers, employees, agents and volunteers, are not liable or responsible for any injuries, illness, damage or losses which may result from your using the materials or ideas, or from your performing the experiments or procedures depicted in this presentation. The Living with the Lab logos should remain attached to each slide, and the work should be attributed to Louisiana Tech University. If you do not agree, then please do not view this content. boosting application-focused learning through student ownership of learning platforms
3
How do computers work? Use digital electronics
Computer memory and chips keep track of large numbers of on/off “switches” A switch that is off is associated with a binary number of 0 A switch that is on is associated with a binary number 1 Patterns of “on” and “off” stored inside a computer are used to encode ordinary numbers Computer processors that use strings of 64 binary numbers to keep track of things are called 64-bit systems
4
What is binary? Base 10 is the most commonly used number system (10 digits): Binary number system uses base 2 (2 digits): 0 1 A single unit of information is called a bit. In binary a bit can be a 0 or a 1 How many combinations can a 4-bit register represent? 1 1 1 1 Total number of bits being represented 24 =16 1 Each bit can be 2 options: 0 or 1
5
What are all the possible combinations of zeros and ones that a 4-bit register can represent?
= 0 1 = 6 1 = 12 Number the bits starting with 0 1 1 = 1 1 = 13 = 7 1 2 3 1 1 = ? = 3 = 2 1 = 14 1 = ? = 2 1 = 8 1 1 = ? = 3 1 = 15 = 9 21=2 20=1 2+1=3 1 1 = 4 = 10 1 = 5 1 = 11 If there is a 1 in the bit, set 2 as the base and raise it to the bit number. If there is more than one bit with a 1 add their values together.
6
Successive Division by 2 for Decimal to Binary Conversion
Convert the decimal value 47 to binary using successive division by 2 Divided by 2, because binary is base 2 LSB – Least Significant Bit 47 ÷2 = 𝑤𝑖𝑡ℎ 𝑎 𝑟𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 𝑜𝑓 1 23 ÷2 = 𝑤𝑖𝑡ℎ 𝑎 𝑟𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 𝑜𝑓 1 11 ÷2 = 𝑤𝑖𝑡ℎ 𝑎 𝑟𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 𝑜𝑓 1 47 to binary is 5÷2 = 𝑤𝑖𝑡ℎ 𝑎 𝑟𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 𝑜𝑓 1 2÷2 = 𝑤𝑖𝑡ℎ 𝑎 𝑟𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 𝑜𝑓 0 1÷2 = 𝑤𝑖𝑡ℎ 𝑎 𝑟𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 𝑜𝑓 1 MSB – Most Significant Bit
7
Data Types Variables store information in the form of bits
Predefined data types allow you to choose the best form for a variable Do you know of any data types? int float Data Type # of Bits Range Comments boolean 8 True or false True ≠ 0 and False = 0 byte 0 to 255 An unsigned 8 bit number (28=256) int 16 -32,768 to 32,767 Whole number, signed (+ or -), most common data type long 32 -2,147,483,648 to 2,147,483,647 Frequently used data type, number with many digits, signed float x1038 to x1038 Includes decimal point, total precision is 6 to 7 digits Data Type # of Bits Range Comments boolean 8 True or false True ≠ 0 and False = 0 byte 0 to 255 An unsigned 8 bit number (28=256) int 16 -32,768 to 32,767 Whole number, signed (+ or -), most common data type long 32 -2,147,483,648 to 2,147,483,647 Frequently used data type, number with many digits, signed float x1038 to x1038 Includes decimal point, total precision is 6 to 7 digits char One 8-bit ASCII character Alphanumeric characters, multiple characters called strings Data Type # of Bits Range Comments boolean 8 True or false True ≠ 0 and False = 0 byte 0 to 255 An unsigned 8 bit number (28=256) int 16 -32,768 to 32,767 Whole number, signed (+ or -), most common data type float 32 x1038 to x1038 Includes decimal point, total precision is 6 to 7 digits Data Type # of Bits Range Comments int 16 -32,768 to 32,767 Whole number, signed (+ or -), most common data type Data Type # of Bits Range Comments int 16 -32,768 to 32,767 Whole number, signed (+ or -), most common data type float 32 x1038 to x1038 Includes decimal point, total precision is 6 to 7 digits Data Type # of Bits Range Comments boolean 8 True or false True ≠ 0 and False = 0 int 16 -32,768 to 32,767 Whole number, signed (+ or -), most common data type float 32 x1038 to x1038 Includes decimal point, total precision is 6 to 7 digits
8
Experimenting with Data Types
5V analog input 5 thermistor 10kW Build the thermistor circuit on your breadboard Activity 1: Collect 100 temperature values and take the average of the values. Provide the average value in Degrees Celsius Print information collected and calculated on the serial monitor Hint: Adapt the program from Question 1 from Homework 1 Truncation is the cutting off of values after the decimal place which can give you errors Using the proper Data Types and including decimals within the equation being calculated can help fix this issue Using the serial monitor to print values is a great troubleshooting tool. Always check your values! Activity 2: Collect 100 temperature values and find the minimum. Provide the minimum in Degrees Celsius
9
Experimenting with Data Types
Activity 3: Collect 100 temperature values and find the min and subtract it from the data set. Then find the average of the remaining values. Provide both min and average in Degrees Celsius Tips for Programming Use the appropriate data type Print out everything you calculate Start with small pieces that build towards the larger program Comment the lines of code to help you remember their purpose
10
Additional Activities
analog input 5 thermistor 10kW Collect 100 temperature values and find the maximum Collect 100 temperature values and find the min, max, and average Collect 100 temperature values and find the min, max, subtract out the min and the max values then find the average of the remaining values. Write a sketch that reads values from the thermistor circuit and prints the analog values, degrees in Celsius, and degrees in Fahrenheit. Beware of truncation and use the right data types.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.