project 1: bits, bytes, and basicslindsaymattock.net/teachingfiles/cfproject1.pdf · project 1:...
TRANSCRIPT
![Page 1: Project 1: Bits, Bytes, and Basicslindsaymattock.net/teachingfiles/CFProject1.pdf · Project 1: Bits, Bytes, and Basics This week we are going to explore how information is represented](https://reader034.vdocuments.net/reader034/viewer/2022042805/5f5fc91a85cb8e33d375df79/html5/thumbnails/1.jpg)
1
Project1:Bits,Bytes,andBasicsThisweekwearegoingtoexplorehowinformationisrepresentedinbinarycode.Binarycodeisthemachinecodeormachinelanguage.Thesearethe1’sand0’sthatrepresentthebitsandBytesthatmakeupcomputerprogramsorthedataprocessedbythecomputer.Everythingthatyouseeonyourcomputerscreencanbereducedtobinarycode,althoughmostusersofcomputershavefewreasonstointeractwiththecomputeratthislevel.Thiswillbeoneoftheraretimeswhenyouwillmanipulatebinarydata,butthisprojectprovidesanopportunitytofurtherexploretherelationshipbetweenwhatyouseenonthescreenandwhatisgoingoninsidethemachine.Project2Objectives:Bytheendofthisprojectyouwillbeableto:
- CalculatethevalueofBytesusingbinaryaddition- Readabinaryclock- Explainhowtextandcolorarerepresentedinbinary- Useahexeditortomanipulatebinarycode- Definetherelationshipbetweenthelogical,physical,andconceptualfacetsofa
digitalobjectThisweekKennethThibodeaudiscussedthevariouslayersofadigitalobject:thephysicalobject,thelogicalobject,andtheconceptualobject.ThefollowingdefinitionsaretakenfromUNESCO’sGuidelinesforthePreservationofDigitalHeritage,page35(availableathttp://unesdoc.unesco.org/images/0013/001300/130071e.pdf).
“Asphysicalobjects,consistingof‘inscriptions’(usuallybinarystatesof‘on-ness’or‘off-ness’)oncarriermediasuchascomputerdisksortapes.(Despitetheimpressionofthattheyexistin‘cyberspace’,evenonlineresources
mustexistonphysicalcarrierssomewhere)”
“Aslogicalobjectsconsistingofcomputerreadablecode,whoseexistenceatanyparticulartimedependsonthephysicalinscriptionsbutisnottiedtoanyparticular
carrier”
![Page 2: Project 1: Bits, Bytes, and Basicslindsaymattock.net/teachingfiles/CFProject1.pdf · Project 1: Bits, Bytes, and Basics This week we are going to explore how information is represented](https://reader034.vdocuments.net/reader034/viewer/2022042805/5f5fc91a85cb8e33d375df79/html5/thumbnails/2.jpg)
2
“Asconceptualobjectsthathavemeaningtohumans,unlikethelogicalorphysicalobjectsthatencodethemat
anyparticulartime.(Thisisrecognisableastheperformancepresentedtoauser)”
Thisprojectwillexploretherelationshipbetweenthelogicalandconceptualobject–thebitsandbytesthatthecomputertranslatesintotherepresentationsofinformationonthescreenthatwecanunderstand.Whatisabit?AsyoureadinPetzoldthisweek,bitsarethesmallestunitofstorageinabinarysystem-thatis,thesmallestunitofinformationprocessedbyacomputer.Informationisstoredas0or1.YouareprobablymorefamiliarwiththetermByte–agroupof8bits.
KilobyteKB=1,000BytesMegabyteMB=1millionBytesGigabyteGB=1billionBytesTerabyteTB=1trillionBytes
Onebitgivesustwopatterns:1and0.2bitsallowforfourpatterns:00,11,01,10.Everytimeweaddonebittothelengthofourbitstring,wedoublethenumberofavailablepatterns.So,8bitsor1Byteprovidesameansforrepresenting256differentpatterns,asillustratedinthischart:
1bit–2patterns(21)2bits–4(22)3bits–8(23)4bits–16(24)5bits–32(25)6bits–64(26)7bits–128(27)8bits–256(28)nbits-2npatterns
![Page 3: Project 1: Bits, Bytes, and Basicslindsaymattock.net/teachingfiles/CFProject1.pdf · Project 1: Bits, Bytes, and Basics This week we are going to explore how information is represented](https://reader034.vdocuments.net/reader034/viewer/2022042805/5f5fc91a85cb8e33d375df79/html5/thumbnails/3.jpg)
3
RepresentingNumbersinBytesSomeofthefirstcomputerswerecalculators,sowe’llstartwithnumbers.If8bitsor1Byteprovides256patterns,thenwecanrepresent256numbersinbinary.So,howdoesthiswork?Tostart,inbinarymatha1hasavalueoris“on”whilea0doesnothaveavalueoris“off.”
Q1:If8bitsor1Bytecanrepresent256patterns,whatistherangeofpositiveintegersthatcanberepresentedinasingleByte?(e.g.1-10)
Followingthelogicfromthechartinsection1,eachbitrepresents2npower.Inbinarymathwemovefromrighttoleft,growingexponentiallyaswego.Eachngrowsbyonerepresentingthegrowthinthenumberof“bits”ofinformationwecanencode(Reminder:Anythingtothepowerof“0”=1).ThefollowingillustrateshowyouwouldcalculatethevalueoftheByte11111111.Startingontheleftourfirst1represents20or1,thesecond21or2,andsoonuntilwereachoureighth1whichequals27or128.TocalculatethetotalvalueofthisByte,youaddupalloftheorangenumbers.
1 1 1 1 1 1 1 1 27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
Q2:Whatisthesumof1+2+4+8+16+32+64+128?Giventhetotal,doyouneedtoreviseyourresponsetoQ1?
Q3:Usingthediagramabove,whatwouldaByterepresentingthenumber0looklike?
![Page 4: Project 1: Bits, Bytes, and Basicslindsaymattock.net/teachingfiles/CFProject1.pdf · Project 1: Bits, Bytes, and Basics This week we are going to explore how information is represented](https://reader034.vdocuments.net/reader034/viewer/2022042805/5f5fc91a85cb8e33d375df79/html5/thumbnails/4.jpg)
4
Nowlet’sdosomebasicbinarymath.ConsidertheByte00010101.Howdoweconvertthistoanumber?Inthiscase,the0s=0.Remember,0=off.The1swillhaveavalue.So,tocalculatethevalueofthisBytewecarrydownthevalueofeachofthe1sinthebitstringstartingontherightandworkingtotheleft.
0 0 0 1 0 1 0 1 27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
0 0 0 16 0 4 0 1 So,thisBytehasthevalueof16+4+1or21.
Q4:Usingthesamelogic,calculatethevalueoftheByte01101101.
Q5:Nowtryworkingtheotherway.Howwouldyourepresentthedecimalnumber40inbinary?(Hint:thisdoesn’tinvolveanyadvancedmath,takealookattheorangenumbersinthediagramabove.)
YoucancheckyouranswerswiththeDecimal–Hexadecimal–BinaryConversionTableathttps://www.eecis.udel.edu/~amer/CISC651/ASCII-Conversion-Chart.pdf.Fornow,lookattheDecimalcolumnforyournumberandtheBinarycolumnforthecorrectbinaryrepresentation.Youcanalsoadd,subtract,divide,andmultiplyinbinary,seehttp://academic.evergreen.edu/projects/biophysics/technotes/misc/bin_math.htm
![Page 5: Project 1: Bits, Bytes, and Basicslindsaymattock.net/teachingfiles/CFProject1.pdf · Project 1: Bits, Bytes, and Basics This week we are going to explore how information is represented](https://reader034.vdocuments.net/reader034/viewer/2022042805/5f5fc91a85cb8e33d375df79/html5/thumbnails/5.jpg)
5
ReadingaBinaryClockNowthatyouunderstandthebasicsofbinaryaddition,youcanreadabinaryclock.AbinaryclockonlyrequiresafewbitstorepresenteachofthenumbersinatraditionalHH:MM:SSrepresentationoftime.Thediagramfromthepreviousexampleisflippedonitsside,sothatthebitsareaddedfrombottomtotopratherthanrighttoleft.Fromtoptobottomeachbitgrowsexponentially,aswithourprevious8bitexample.
HH MM SS
8 23
4 22
2 21
1 20
![Page 6: Project 1: Bits, Bytes, and Basicslindsaymattock.net/teachingfiles/CFProject1.pdf · Project 1: Bits, Bytes, and Basics This week we are going to explore how information is represented](https://reader034.vdocuments.net/reader034/viewer/2022042805/5f5fc91a85cb8e33d375df79/html5/thumbnails/6.jpg)
6
So,ifwewantedtorepresentthetime9:10:25AM,itwouldlooklikethis(orange=onor1,black=offor0:
0 9:1 0:2 5
Intheexampleabove,thefirstdigitofthehourshasnobits“on”sothetotalis0.Inthesecond,thefirstandfourthareonrepresenting1and8,soweaddthesetogethertototal9.Theonebitofthefirstminutespositionisonforthe1inour10,thesecondisoffforthe0inthe10.Inthefirstsecondscolumnthesecondbitisonrepresenting2.And,inthefinalcolumnthefirstandthirdbitsareon,representing1and4tototalto5.
HH MM SS
8 23
4 22
2 21
1 20
![Page 7: Project 1: Bits, Bytes, and Basicslindsaymattock.net/teachingfiles/CFProject1.pdf · Project 1: Bits, Bytes, and Basics This week we are going to explore how information is represented](https://reader034.vdocuments.net/reader034/viewer/2022042805/5f5fc91a85cb8e33d375df79/html5/thumbnails/7.jpg)
7
BinaryclockstypicallyrepresentMilitaryor24-hourtime(forachartsee:http://militarytimechart.com/),so9:10:25PMwouldberepresentedas21:10:25,likethis:
2 1:1 0:2 5
Checkouthttp://binary.onlineclock.net/toseeabinaryclockinaction.
Q6:Inyourownwords,explainwhyweonlyneed4bitsfortheseconddigitofthehours,minutes,andseconds;3bitsforthefirstdigitofthesecondsandminutes;and2bitsforthefirstdigitofthehourstorepresenttimeinthismanner.
HH MM SS
8 23
4 22
2 21
1 20
![Page 8: Project 1: Bits, Bytes, and Basicslindsaymattock.net/teachingfiles/CFProject1.pdf · Project 1: Bits, Bytes, and Basics This week we are going to explore how information is represented](https://reader034.vdocuments.net/reader034/viewer/2022042805/5f5fc91a85cb8e33d375df79/html5/thumbnails/8.jpg)
8
Q7:Whattimeisrepresentedinthefollowingtwoexamples?Pleasegiveyouranswersin24-hourtimeandintraditional12-hourtime.
HH MM SS
8 23
4 22
2 21
1 20
HH MM SS
8 23
4 22
2 21
1 20
![Page 9: Project 1: Bits, Bytes, and Basicslindsaymattock.net/teachingfiles/CFProject1.pdf · Project 1: Bits, Bytes, and Basics This week we are going to explore how information is represented](https://reader034.vdocuments.net/reader034/viewer/2022042805/5f5fc91a85cb8e33d375df79/html5/thumbnails/9.jpg)
9
RepresentingOtherInformationinBinaryToday,computersaremuchmorethancalculators.Alloftheinformationthatyouseeonyourcomputerscreenisprocessedasbinarycode.Remember,asingleBytecanholdquiteabitofinformation,givingus256differentopportunitiestorepresentdifferentpiecesofinformation.Thismeansthatwecantakeanythingwithlessthan256valuesandrepresentitinbinarycode.Whataboutlettersandnumerals?OuralphabetA-Zandnumbers1-10canberepresentedinonesingleByteofinformationwithlotsofroomtospare.Takeforexamplethenumber61.Torepresentthenumberasadecimaldigit(thatisabase-10numberfromthefirstexample)wecanuseoneByte:
0 0 1 1 1 1 0 1 27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
0 0 32 16 8 4 0 1 1+4+8+16+32=61.But,whatifwewantedtorepresenteachoftheindividualcharacters6and1asnumerals?Thisiswherecharacterencodingschemascomeintothepicture.Thereareanumberofdifferentencodingschemasoutthereintheworld,butwewilluseASCIIortheAmericanStandardCodeforInformationInterchangeasanexample.Seehttps://www.w3schools.com/charsets/ref_html_ascii.aspformoreinformationonASCII.TakeanotherlookattheDecimal–Hexadecimal–BinaryConversionTableathttps://www.eecis.udel.edu/~amer/CISC651/ASCII-Conversion-Chart.pdf.InthefirstexamplewhenwewerecalculatingthedecimalvalueofeachoftheBytes,weusedthedecimalandbinarycolumns.Nowwe’lllookattheASCIIandBinarycolumns.Asthechartillustrates,eachletter,number,orcharacterhasbeenassignedtoaparticularsetofbits(0-32arecontrolcharacters,don’tworryaboutthese).LookingtheASCIIcolumnyoucanseethatthenumeral6hasbeenassignedto00110110andthenumeral1to00110001.Notethatthesecorrespondtothedecimalnumbers54and49.Inthiscaseinsteadofrepresentingnumbers,theseparticularByteswereassignedtorepresentparticularcharactersonthekeyboard.So,whilethedecimaldigit61canberepresentedinasingleByte00111101,thenumeral61isrepresentedintwoASCIIBytes00110110 00110001.ThisisthesetofBytesthatarereturnedtothecomputerwhenyoutype6and1inawordprocessingprogram.
![Page 10: Project 1: Bits, Bytes, and Basicslindsaymattock.net/teachingfiles/CFProject1.pdf · Project 1: Bits, Bytes, and Basics This week we are going to explore how information is represented](https://reader034.vdocuments.net/reader034/viewer/2022042805/5f5fc91a85cb8e33d375df79/html5/thumbnails/10.jpg)
10
WordsbecomejuststringsofASCIIBytes.Thephrase“HelloWorld!”wouldappearinbinaryas: 01001000 01100101 01101100 01101100 01101111 00100000 01010111 01101111 01110010 01101100 01100100 00100001
Q8:Noticethatthephrasehasatotalof10lettersandanexclamationpoint,butthereare12Bytesinthebitstringabove.UsingtheASCIIchart,explainwhythisis.
Q9:GivenwhatyouhavejustlearnedaboutASCIIencoding,isthereadifferencebetweenthebinaryrepresentationsof“byte”,“Byte,”and“BYTE”?
BeforeASCIIencodingwasstandardizedintheearly1980s,differentcomputerswouldusedifferentstandardsforencodingtext.ComputerswereprogrammedbypunchingthebinarycodeintocardboardcardscalledPunchedCards(youreadabitaboutthisintheStephensonreadinglastweek).TakeafewminutestoexplorethedifferentstandardsandpunchavirtualcardwiththePunchCardEmulatorhttp://www.kloth.net/services/cardpunch.php.YoucanlearnmoreaboutPunchedCardsathttp://homepage.cs.uiowa.edu/~jones/cards/codes.html.
Q10:LookcloselyattheASCIIcolumnoftheASCIIchart.Asa1Byteencodingschema,whatlimitationsdoyousee?(Hint:comparetheASCIIcharttothechartathttps://unicode-table.com).
![Page 11: Project 1: Bits, Bytes, and Basicslindsaymattock.net/teachingfiles/CFProject1.pdf · Project 1: Bits, Bytes, and Basics This week we are going to explore how information is represented](https://reader034.vdocuments.net/reader034/viewer/2022042805/5f5fc91a85cb8e33d375df79/html5/thumbnails/11.jpg)
11
RepresentingOtherInformationAgain,alloftheinformationthatyouencounteronyourcomputerisprocessedasbinarycode.WithasingleBytewecanrepresent256discretepiecesofinformation–anyinformationthatwe’dlike.Whataboutcolor?IfweuseasingleByteor8-bitstorepresentcolor,wecanrepresentatotalof256differentcolors.However,weperceiveamuchwiderrangeofcolors,sotoextendthepalettewecanrepresentcolorsusingmorebits.Aswithtextencodingstandards,therearemanydifferentcolorencodingschemas.Considerthedifferencebetweenthecolorpaletteonoldvideogamesystemsascomparedtowhatyouseeonyourcomputerscreentoday.Marioisagreatexample.TheoriginalNintendoused8-bitcolor,butSuperNintendoused16-bitcolorgivingawiderrangeofcolorstorepresentthegraphicsinthegame.
Imagefromhttp://i.imgur.com/UqHhN.png
![Page 12: Project 1: Bits, Bytes, and Basicslindsaymattock.net/teachingfiles/CFProject1.pdf · Project 1: Bits, Bytes, and Basics This week we are going to explore how information is represented](https://reader034.vdocuments.net/reader034/viewer/2022042805/5f5fc91a85cb8e33d375df79/html5/thumbnails/12.jpg)
12
In8-bitcolor,eachcolorisrepresentedin8-bitsor1Bytegivingacolorpaletteof256colors.16-bitcolorincreasesthenumberofcolorsinthepalettebyafactoroftwo,representingover65,000differentcolorsbyusing16-bitsor2Bytestorepresenteachcolor(256x256=65,536).But,ifyourecall,theprimarycolorsoflightarered,green,andblue.WhatifwedecidedtorepresenteachoftheseprimarycolorsintheirownByteofinformation?
Q11:IfwerepresentedeachoftheprimarycolorsoflightasasingleBytetocreatecolorsinthreeBytes(oneByteforeachcolor00000000 00000000 00000000),howmanydifferentcolorscouldberepresented?
Iwon’tleaveyouinsuspenseonthisone.EachBytegivesus256differentpatterns,sotocalculatethetotalnumberofcolorsavailableinthreeByteswetake256x256x256or16,777,216.
Q12:InourthreeBytestring00000000 00000000 00000000howmanybitsarerepresented?
InourMarioexamples,welookedat8-bitand16-bitcolor.Thisparticularencodingofcolorsacross3Bytesis24-bitcoloror24-bitRGBforRedGreenandBlue.Ifyou’veplayedwiththecolorslidersinMicrosoftOffice,thenyou’veseen24-bitcolorinaction.
![Page 13: Project 1: Bits, Bytes, and Basicslindsaymattock.net/teachingfiles/CFProject1.pdf · Project 1: Bits, Bytes, and Basics This week we are going to explore how information is represented](https://reader034.vdocuments.net/reader034/viewer/2022042805/5f5fc91a85cb8e33d375df79/html5/thumbnails/13.jpg)
13
Intheleftimageabove,allthreecolors(redgreenandblue)aresettotheirmaximumvalueor255.Asthecolorchartillustrates,whiteiscreatedbyblendingallofthecolorstogether.Sotocreatewhitein24-bitRGBcolor,allthreeBytesaresetto1s:11111111 11111111 11111111.RememberfromouradditionexercisesthetotaldecimalvaluefortheByte11111111is255. Thecolorblackistheabsenceoflight,sothecolorblackisrepresentedas0s.00000000 00000000 00000000 Thismeansthatthecolorredcanberepresentedas:11111111 00000000 00000000(equaltothedecimaldigits255,0,0) Greencanberepresentedas:00000000 11111111 00000000(equaltothedecimaldigits0,255,0) And,bluecanberepresentedas:00000000 00000000 11111111(equaltothedecimaldigits0,0,255)
![Page 14: Project 1: Bits, Bytes, and Basicslindsaymattock.net/teachingfiles/CFProject1.pdf · Project 1: Bits, Bytes, and Basics This week we are going to explore how information is represented](https://reader034.vdocuments.net/reader034/viewer/2022042805/5f5fc91a85cb8e33d375df79/html5/thumbnails/14.jpg)
14
Q13:Giventhislogic,howwouldthecolorsMagenta,Cyan,andYellowberepresentedinbinary?YoucancheckyouranswerswiththisRGBColorCodesCharthttp://www.rapidtables.com/web/color/RGB_Color.htm.
So,ina24-bitcolordigitalimage,thecolorforeachpixelwouldbeencodedasthreeBytes:
Digitalsoundisencodedinasimilarway.Inthefollowingimageisanexampleof16-bitencodedsound.Digitalrecordingsarecreatedbytakingsamplesofsoundataspecificrate.“CDquality”soundissampledat44.1kHz(kilohertz)or44,100timespersecond.Thismeansthat44,100timespersecond,aprogrammeasuresandrecordstheheightofasound’ssoundwaveandthentranslatestheheighttoabinaryrepresentationin16-bitsor2Bytes.
11111111 00000000 00000000
00000000 11111111 00000000
00000000 00000000 11111111
![Page 15: Project 1: Bits, Bytes, and Basicslindsaymattock.net/teachingfiles/CFProject1.pdf · Project 1: Bits, Bytes, and Basics This week we are going to explore how information is represented](https://reader034.vdocuments.net/reader034/viewer/2022042805/5f5fc91a85cb8e33d375df79/html5/thumbnails/15.jpg)
15
!!Don’tgetcaughtinthedetails.Theimportanttakeawayhereisthatanypieceofinformationcanberepresentedinbitsandtheninterpretedbythecomputer.Youwillneverhavetoworkwiththemachineatthislevel.We’lltalkmoreaboutprogrammingnextweek.Fornow,justknowthatbehindthesceneseverythingthatyouinputintothecomputerandeverythingthatisoutputtedisatsomepointintheprocessastringofbits.
![Page 16: Project 1: Bits, Bytes, and Basicslindsaymattock.net/teachingfiles/CFProject1.pdf · Project 1: Bits, Bytes, and Basics This week we are going to explore how information is represented](https://reader034.vdocuments.net/reader034/viewer/2022042805/5f5fc91a85cb8e33d375df79/html5/thumbnails/16.jpg)
16
HexandBitstreamsIfyoutakealookattheDecimal–Hexadecimal–BinaryConversionTable(https://www.eecis.udel.edu/~amer/CISC651/ASCII-Conversion-Chart.pdf)fromearlier,youwillnotethatthereareafewcolumnsthatwedidn’ttalkabout–OctalandHex.Petzold’s“BytesandHex”chapterexplainedthedetailsofHexidecimalencoding.Whatisimportanttounderstandhereisthatalongwithbinary,thereareotherwaystorepresentnumbersandstringofBytesorbitstreams.Ifbinaryisbase-2anddecimalisbase-10,thenoctalisbase-8andhexadecimalorhexisbase-16.Whatthismeansforusisthatwecanrepresentmorebitswithfewersymbols.Hexidecimalcodeisawayofrepresenting8-bitBytesinjusttwosymbols.Takeforexample,thecharacterZ.Lookatyourchart.InbinaryZisrepresentedas01011010(orthedecimaldigit90).Inhexthisstringofbitscanberepresentedsimplyas5A.
Q14:Takeamomenttoexplainthedifferencebetweenthedecimaldigit,thehexrepresentation,andASCIIcodeinyourownwords.
Our24-bitcolorpalettegivesusanotherexample.OpentheRGBColorCodesChart(http://www.rapidtables.com/web/color/RGB_Color.htm)andselectthecolorwhite.BelowtheR,G,andB,youshouldseeanothercodeprecededbya#symbol.Thisisthehexcodeforthecolor.Wecanrepresentthecolorwiththebits11111111 11111111 11111111,orwecanusethecorrespondingdecimaldigits255 255 255,orwecanusethehexvalueFFFFFF.WewillseelaterwhenweworkwithHTMLthatthisisexactlyhowyounamethecolorvaluethatyouwouldliketouseinyourformatting(seehttps://www.w3schools.com/colors/colors_picker.asp).
![Page 17: Project 1: Bits, Bytes, and Basicslindsaymattock.net/teachingfiles/CFProject1.pdf · Project 1: Bits, Bytes, and Basics This week we are going to explore how information is represented](https://reader034.vdocuments.net/reader034/viewer/2022042805/5f5fc91a85cb8e33d375df79/html5/thumbnails/17.jpg)
17
ManipulatingBitstreamswithaHexEditorNowthatyouarefamiliarwithhex,wecanexperimentabitwithahexeditor.Ahexeditorisaprogramthatallowsforthedirectmanipulationofthebinarydataofacomputerfile.Firstdownloadthehelloworld.txtfilefromthecoursewebsite.Thisisaplaintextfile,meaningthatthetextcharactersareencodedinastandardcodingschemalikeASCII.Inthisexample,thetexthasbeenencodedintheUnicodeUTF-8standard.Ifyouopenthefileyoushouldseethefamiliarphrase“HelloWorld!”
Nowlet’slookatthebitsandBytesthatmakeupthisfile.OpentheHexEd.ithexeditorathttps://hexed.it/inyourwebbrowser,andclick“OpenFile”inthemenubar,andopenhelloworld.txtfromyourcomputer.Youshouldseesomethinglikethis:
Thefirstsetofnumbersthatyouseeontheleft(00000000)isareferencetowhereyouareinthefile.Thisnotaparticularlylargefile,soweonlyhaveonelinetoreference.InthemiddleofthescreenweseeeachByterepresentedinhex.And,ontherightweseetheinterpretedtextencodedaccordingtoUTF-8.Notethatthe“.”representsaspace.
Q15:Basedonwhatyouseeinthehexeditor,howlargewouldyouexpectthisfiletobeinbitsandBytes?
UTF-8isverysimilartoASCII,soyoucanusetheDecimal–Hexadecimal–BinaryConversionTable(https://www.eecis.udel.edu/~amer/CISC651/ASCII-Conversion-Chart.pdf)toconfirmthatthehexcorrespondstotheencodedletter.
![Page 18: Project 1: Bits, Bytes, and Basicslindsaymattock.net/teachingfiles/CFProject1.pdf · Project 1: Bits, Bytes, and Basics This week we are going to explore how information is represented](https://reader034.vdocuments.net/reader034/viewer/2022042805/5f5fc91a85cb8e33d375df79/html5/thumbnails/18.jpg)
18
Earlierwedeterminedthat“HelloWorld!”wouldlooklikethisinbinary: 01001000 01100101 01101100 01101100 01101111 00100000 01010111 01101111 01110010 01101100 01100100 00100001 Asthechartdemonstrates,thehexcode48 65 6C 6C 6F 20 57 6F 72 6C 64 21isequivalenttothisbinaryrepresentation.Hex,issimplyashort-handforbinarycode.Withthehexeditor,youcanmodifythisfilebymodifyingthehex.Usingthehexeditoryouaremodifyingtheverybitstream(thebinaryrepresentationofthefile).Youcandothisintwoways:(1)selectingthetextinthetextpaneandtypingasyouwouldinanytexteditoror(2)usingtheConversionCharttowritethehexinthehexpanel.
Q16:Usingthehexeditor,modifythefile,exportittoyourcomputer,andopenitinatexteditortoseethechangesthatyoujustmadetothefile.Explainyourprocessinyournotebook.
Now,downloadhelloworld.rftfromourcoursesite.An.rtffileisonesavedinaRichTextFormat.Notethatthetextisthesameasthepreviousfile;howeverthe.rtfspecificationallowsformoreformattingthananPlainTextfile,whichmeansthattheinformationcontainedwithinthefileisencodeddifferently.You’llnoticethatwehaveafewformattingoptionswithRichText,suchasfont,style,size,andcolor.(Ifyouarecurious,youcanreviewtheRTFformatspecsathttp://www.biblioscape.com/rtf15_spec.htm).
![Page 19: Project 1: Bits, Bytes, and Basicslindsaymattock.net/teachingfiles/CFProject1.pdf · Project 1: Bits, Bytes, and Basics This week we are going to explore how information is represented](https://reader034.vdocuments.net/reader034/viewer/2022042805/5f5fc91a85cb8e33d375df79/html5/thumbnails/19.jpg)
19
Openhelloworld.rtfinthetexteditor.Youshouldnowseesomethinglikethis:
Lookingatthetextpane,youcannowseethebinarycodeinterpreted.Ourtextthatweseewhenweopenthefileinthetexteditorisattheverybottomofthefilebeforetheend}.Therestoftheinformationistheformattinginformationforthe.rtffile.Thisishiddenfromuswhenweopenthefilenormally,butinterpretedbehindthescenesbythetexteditingprogram.
Q17:Takealookatthetextpane,whatformattinginformationcanyouinterpretfromthebinarycode?
Q18:HowlargeisthisfileinBytes?Howdoesthiscomparetothe.txtfile?
![Page 20: Project 1: Bits, Bytes, and Basicslindsaymattock.net/teachingfiles/CFProject1.pdf · Project 1: Bits, Bytes, and Basics This week we are going to explore how information is represented](https://reader034.vdocuments.net/reader034/viewer/2022042805/5f5fc91a85cb8e33d375df79/html5/thumbnails/20.jpg)
20
Nowlet’scomparethe.txtand.rtffilestoaWordDocument.Downloadthehelloworld.docxfilefromthecoursesite.Aswiththeothertwoexamples,thetextisthesame.
![Page 21: Project 1: Bits, Bytes, and Basicslindsaymattock.net/teachingfiles/CFProject1.pdf · Project 1: Bits, Bytes, and Basics This week we are going to explore how information is represented](https://reader034.vdocuments.net/reader034/viewer/2022042805/5f5fc91a85cb8e33d375df79/html5/thumbnails/21.jpg)
21
Nowopenhelloworld.docxinthehexeditor.
Thisfileshouldlookcompletelydifferent.Inthiscase,wehaveamuchlargerfile(almosttwicethesize)withmoreinformationencoded.Thetextpaneontherightnolongermakessensebecausethisinformationisencodedforthemachineandnotforus..rtffilesarearelativelysimplyfileformatanditjustsohappensthattheinformationisencodedinawaythatwecantranslatetheinformationwhenitisdecodedastext.Thisisn’talwaystrue,aswecanseewiththeWorddocument.Aswiththe.rtfwhatyouseehereisalloftheinformationthatthemachineneedstorenderthefileinthewaythatyouseeitwhenyouopenthefileinWord.Unlikethe.txtand.rtffiles,theinformationisencodedinawaythatcannotbeeasilyinterpretedbyus.
Q19:Whatinformationaboutthisfilecanyouidentifyinthehexeditor?
Q20:Usingthedefinitionsofphysical,logical,andconceptualobjectsfrompage1,explaintheselayersofadigitalobjectinyourownworks,referringtothehelloworldexamplesandyourexperienceusingthehexeditor.
![Page 22: Project 1: Bits, Bytes, and Basicslindsaymattock.net/teachingfiles/CFProject1.pdf · Project 1: Bits, Bytes, and Basics This week we are going to explore how information is represented](https://reader034.vdocuments.net/reader034/viewer/2022042805/5f5fc91a85cb8e33d375df79/html5/thumbnails/22.jpg)
22
NotebookQuestions:Alloftherequirednotebookquestionsarelistedhereforyoutoreference.Besuretoanswereachquestioncompletelyinyournotebook,includinganexplanationofhowyouarrivedatyouranswer.Question PagenumberQ1:If8bitsor1Bytecanrepresent256patterns,whatistherangeofpositiveintegersthatcanberepresentedinasingleByte?(e.g.1-10) 3
Q2:Whatisthesumof1+2+4+8+16+32+64+128?Giventhetotal,doyouneedtoreviseyourresponsetoQ1? 3
Q3:Usingthediagramabove,whatwouldaByterepresentingthenumber0looklike? 3
Q4:Usingthesamelogic,calculatethevalueoftheByte01101101. 4Q5:Nowtryworkingtheotherway.Howwouldyourepresentthedecimalnumber40inbinary?(Hint:thisdoesn’tinvolveanyadvancedmath,takealookattheorangenumbersinthediagramabove.)
4
Q6:Inyourownwords,explainwhyweonlyneed4bitsfortheseconddigitofthehours,minutes,andseconds;3bitsforthefirstdigitofthesecondsandminutes;and2bitsforthefirstdigitofthehourstorepresenttimeinthismanner.
7
Q7:Whattimeisrepresentedinthefollowingtwoexamples?Pleasegiveyouranswersin24-hourtimeandintraditional12-hourtime. 8
Q8:Noticethatthephrasehasatotalof10lettersandanexclamationpoint,butthereare12Bytesinthebitstringabove.UsingtheASCIIchart,explainwhythisis.
10
Q9:GivenwhatyouhavejustlearnedaboutASCIIencoding,isthereadifferencebetweenthebinaryrepresentationsof“byte”,“Byte,”and“BYTE”?
10
Q10:LookcloselyattheASCIIcolumnoftheASCIIchart.Asa1Byteencodingschema,whatlimitationsdoyousee?(Hint:comparetheASCIIcharttothechartathttps://unicode-table.com).
10
Q11:IfwerepresentedeachoftheprimarycolorsoflightasasingleBytetocreatecolorsinthreeBytes(oneByteforeachcolor00000000 00000000 00000000),howmanydifferentcolorscouldberepresented?
12
Q12:InourthreeBytestring00000000 00000000 00000000howmanybitsarerepresented? 12
Q13:Giventhislogic,howwouldthecolorsMagenta,Cyan,andYellowberepresentedinbinary?YoucancheckyouranswerswiththisRGBColorCodesCharthttp://www.rapidtables.com/web/color/RGB_Color.htm.
14
Q14:Takeamomenttoexplainthedifferencebetweenthedecimaldigit,thehexrepresentation,andASCIIcodeinyourownwords. 16
Q15:Basedonwhatyouseeinthehexeditor,howlargewouldyouexpect 17
![Page 23: Project 1: Bits, Bytes, and Basicslindsaymattock.net/teachingfiles/CFProject1.pdf · Project 1: Bits, Bytes, and Basics This week we are going to explore how information is represented](https://reader034.vdocuments.net/reader034/viewer/2022042805/5f5fc91a85cb8e33d375df79/html5/thumbnails/23.jpg)
23
thisfiletobeinbitsandBytes? Q16:Usingthehexeditor,modifythefile,exportittoyourcomputer,andopenitinatexteditortoseethechangesthatyoujustmadetothefile.Explainyourprocessinyournotebook.
18
Q17:Takealookatthetextpane,whatformattinginformationcanyouinterpretfromthebinarycode? 19
Q18:HowlargeisthisfileinBytes?Howdoesthiscomparetothe.txtfile? 19Q19:Whatinformationaboutthisfilecanyouidentifyinthehexeditor? 21Q20:Usingthedefinitionsofphysical,logical,andconceptualobjectsfrompage1,explaintheselayersofadigitalobjectinyourownworks,referringtothehelloworldexamplesandyourexperienceusingthehexeditor.
21