Topic 2 - Focusing on int and char, signs, bits/bytes
Outline:
- printf for showing data
- format specifiers are basically the same as python’s %
- naive sign bit, the zero problem
- the sizeof operator
- two’s complement vs. shifting the range (wav)
- hex as groups-of-four-bits
- getting comfortable with max sizes
- ASCII from 5-bits to 7, challenges with 8-bit and encoding
Transcript:
hello
everybody how are all of you tonight and
i wow you're all chatting
and that's very funny cuny we are
actually building
an exact service for streaming which is
a whole other series about CSGFlix
and
um that that's but that's not what we're
talking about tonight because we have
a special guest uh for this session this
is the
c as an additional language session with
the enceladosaurus
did i say it right yeah you got it okay
i totally said it right all right so
and celadosaurus approves of how i'm
saying it uh so
she's on via discord uh she's
a astrophysicist by day
c coder by night um and she's
accepted the challenge to try to learn
um see
she's she mostly you mostly work in
python right
yes yep pretty much exclusively in
python okay
and she just decided that python being
such a beautiful language that it is and
i know everybody in chat agrees with me
because python
she just said well python's doing all
this wonderful stuff for me so i want to
get rid of all of it i want to
deal with all of those things i just
i know suny really loves python but
she's by the way a bit of a python
non-fan you could say
and hello miss sagittarius and strophium
uh
stay safe with constructors we're not
doing c plus plus uh strophium we're
just doing
bare metal c um so we i don't know we
might go on to that
later on but you know for now we're just
getting started with the basics i don't
want to get into all the class
stuff and the oops stuff we're gonna
we're gonna stay like procedure we're
gonna code like it's 1970. actually
we're gonna take
a bunch of the newer features from c and
by newer in c i mean
c 1999. so we're going to program like
it's 1999
in the c99 so the back end of this thing
is hooked up to the c99 standard
and i'm pointing at the thing because
i'm pointing at my screen and that's
you can't see that so i'm gonna i'm
gonna get to that but
we are literally as strophium says we
are literally programming the matrix
so i don't even see it anymore i just
see all right i'm not gonna i'm not
gonna
quote it we all we've all seen it we've
all said now we need some more 90s music
we totally need you know what i have no
no no okay
all right um there's now you gotta have
your background be like
the green the green numbers or whatever
from the matrix instead of the bricks it
should just be like
the matrix whenever we're doing seats
let's do that
okay i will that let me let me make a
note of that matrix
didn't they do some analysis on it it
turned out it was like a sushi recipe or
something that they were like
showing in because there was a bunch of
like japanese and
like random stuff you have blue hair
right now
wow i got bored when i was recovering
from covid and there was
this like conditioner or something you
could put in your hair instead of actual
hair dye
and i was bored and i was sick and i was
like i really need something
that's like a serious anime power-up i
think just happened
yeah you know i i've i had purple and
green hair
in grad school and then volunteering for
the fire department you have to have
natural hair but the fire department is
prohibiting volunteers right now because
of covid so
i was like okay i've gotten this tiny
window thank you virus
where i can have like cool hair from
very sorry i didn't mean to cough in
your knee
caught me off guard so
that is uh that's great yeah it totally
did happen so
um i need to get out of this monologue
we i just want to show
everybody here we've got uh something
new um something something old that's
something new
which is we're gonna go to the learn
screen
blue yeah something blue and
if we if we get that right we've got
this
this is the newest version like as of
minutes ago you can you can check the
github repository i think
let's see what let's see what github
says about it
well this is the multi-user pad
that we're using for tonight's session
and
okay it's it's now calling it an hour
ago but i think they have a
bit of a rounding bit of oh no okay i
pushed it at 6 20. i'll give them an
hour yeah
all right so i just deployed it
so it doesn't match exactly on the time
stamp here but this this
thing is like hot off the press so
this is um this is our new learning tool
and for those who have been here before
uh cool this this is mostly the same
uh a lot changed really on the back end
but we have our whiteboard up here
and we're set to see mode because jesse
doesn't fool around with
you know these other languages i mean we
we have python
we have javascript but we just we don't
have time for that stuff right now like
we're
we're in c mode so lock and load we've
got
you know javascript yeah i'm
totally with you on that but you know
seriously my my manager at work well my
career manager likes to tease me because
my initials are js and so
whenever he was trying to get under my
skin he would just be like all right
javascript and i'm like
oh my god that one would make me cranky
i will try really hard never to make
that joke
that just sounds awful but okay
especially considering like one of
javascript's main
creators brendan ike just is totally
washed his hands of it i don't blame
him i don't blame him i'm sorry if there
are any javascript
programmers there's affirmation in chat
i mean i apologize
for your thing we all have to slum it in
the browser
you know i mean at some point we're
writing javascript
oh my gosh if i ever have a baby boy he
could be chase
wow that's
i actually i saw a twitter handle i
thought was kind of clever about that
the other day
sorry this is not a just chatting
session but we're totally just kidding
but i saw one just just like yesterday
and it was
json born oh god
oh god i mean that's an excellent
username i'm kind of like i
want to go back in time and steal it but
i know it's so good
i totally loved it but um i i
just i don't know if he's any good i
just i followed him
i was like just for the user you got me
on the username i might regret this
later but
anyway i know i know nothing about
json-born but
uh i think i think it's great okay so
where we were last time we had just had
our first intro
uh it was several weeks ago uh jessie's
been having
sorry yeah but she's back in action so
we're doing a little bit of review uh we
were just doing a little bit of warm up
right before the show just to make sure
the tools work and
um jesse uh got a
got a program running here and we have a
brand new feature here
the clear output feature which
some of you might have seen as live code
was you know it actually synchronizes
the call
so there's a bunch of cleanups and
anyway i by no means is multi-user pad
ready for
general use but you know we're we're
getting there it's open sourced it's
got synchronized output clearing we're
just like we're
totally off on features at this point
we're going crazy
yes curse you coved she was she was
out for a little bit and i didn't want
to push her too hard because i feel like
you know even though she was offering to
go like last week and
you know a little bit before that it was
i was like you don't really want to be
doing c
when you're not feeling well because
c is going to make you feel unwell so
you you you want to be at your best
before you go into c oh lord
so i think my uh ulterior motive here is
to teach you that
as much as you're going to know about c
you're probably going to be happier in
python but
that's just my bias i just want to be a
better programmer and
it is great for that that's a great
reason
sorry i got really excited i know i
don't know i mean that's the that's the
enthusiasm right like i
i love programming but i apart from
a smattering of matlab that i learned in
high school because i had to
i've always just written python and i'm
not very good at i'm self-taught like
i love it though that's the thing and i
i want to get better and
from what i've been talking to software
developers i've been asking how do i
how do i get better and they're like
well do you want the easy way or the
nasty way and i'm like well
obviously the nasty way like learn c and
i'm like okay
do you want to get better do you really
want to get better
if you really want to get better this is
it like that
that is right there that is the greatest
reason to learn c um
i was like going to the gym you know
when you haven't gone to the gym in
years and you're like
this is going to hurt this is going to
be horrible but i'm going to thank
myself
this is like climb the great wall and
you know just just do the whole thing
and you haven't been oh wow
well you know what i love to set goals
that seem impossible for me
no it's not impossible but you know
you'll hurt by the time you know it's
it's mostly
flat-ish until it isn't and
you know you'll be in pain at the end
but you will have accomplished something
like pretty serious so oh geez
okay not that i recommend going to china
right now so anyway my bad
bringing that up so yep
very similar to us is pretty bad
actually don't don't come here please
it's just that's just a bad bad analogy
okay but anyway moving on
um so this is our tool we have the
latest version deployed uh this exactly
matches what's in the repo and i don't
recommend you run this at home so
just wait a little bit and just just for
fun i
added just because i was getting annoyed
at doing the deployment
so i added a little scripts directory
and there's this rough install and i
tried to name it
rough install because i it should not
say install i feel like that sets the
wrong expectation
but rough install has
one of the best lines of code that i've
written
which is right here this is the i am
crazy line
yes that and that is it like that
you you real if you really want to do
this like this this program by default
will reject your attempt to install it
and it it will cost you if you really
want to do this then set
i am crazy to yes so the only people who
should be installing this
by script have to declare that they're
crazy so
that's that's as strong a warning as i
can give you so
you might want to just watch the coding
sessions until this thing matures a
little bit more
but anyway that is coming soon
and uh it's mostly written in python so
if you're a python dev then you know
maybe we'll get around to that if you're
around for some of the streams um i
mostly work on that
wednesday nights but right now as uh
suny pointed out
i'm currently building a streaming
service from scratch that's CSGFlix
so pretty much all of the sessions aside
from these learning sessions
with on mondays with with jesse and tien
are the only exceptions everything else
is just
like CSGFlix so that's fun you can
check that out later
but when we get back to normal we'll uh
we'll go back to improving this tool on
stream okay
so that's just
enough to get started you're clever
though as
fellow deep end diver this is the best
way to get it oh and thank you for the
follow us trophy and i appreciate it
um it's the best way trophium is super
super cool just as like a small
introduction from
from my if i remember on your stream
strofium's the dude who built that
um yes planet simulation in yes
okay like all of the cool video game
development
and often astronomy themed super super
super cool
okay well that's thank you strophe i
appreciate it thanks for dropping by
um and i agree this is a good place to
deep dive
uh so all right well
that's enough talk let's
let's let's get to let's get this what
can you do with c
you gain some serious power
oh yeah and that's that's this is
exactly what we're going to do
[Laughter]
love you is the glove that i was telling
is this is it this is the power glove we
are that
that sensor that you saw at the
beginning of the show that is the bn055
it is a nine degree of freedom
uh position sensor it is going to be
going into that
power glove so we are we are going to
hack time but
we're going to get to that a little bit
later okay so no we're we're well beyond
the meme
stroke i can make your power glove print
every
uh uh letter from a to z
you know i really like what you're
saying because i don't know that's a
really good way to warm up we should we
should really
do that we're gonna write it again
you are absolutely right i only get the
power from the power glove when i'm
typing with it on
i uh yeah i'm just gonna have to go a
little bit less power because you know
the enceladosaurus is driving and she's
she's already driving so
yeah this is see it's it's been too much
python in the intervening few weeks
you're just writing pseudocode don't you
even start with me
all right that's that's
pseudocode saves lives all right i i
that's why i like to program in
pseudocode which is python programming
okay and because of oh
lordy that's not the right thing and
then i wanted to end it
i lost track of my brackets there's too
many brackets
oh we could do lisp if you really want
to lose track of your brackets
i looked at google images of lists
when i was like 15 and i was like oh
so someday i'll like so so really tiny
tiny tiny fast story time okay
okay so when i was like eight my mom
made the mistake i loved my mom dearly
she made the mistake of getting me a
college
lecture series on astrophysics and so if
you go back to little baby jess's pink
sparkly diary from the age of eight
there's random doodles of like sailor
moon and stuff and then there's like
complex cosmological
equations that i copied down from this
th this this lecture series i didn't
understand
but i i like told myself as i was
writing them down
someday you're gonna understand this i'm
gonna know this
so then fast forward a couple you know a
decade
and like 16 17 year old jess is learning
matlab and falling in love with
programming but being told she's
terrible at it so you know i'm still
working through that
and we're gonna fix that i learned that
lisp exists
i looked at what the code looked like
and i had that moment of like
someday you will understand i went back
probably in the last few months and i
was like yeah
probably never gonna understand
probably not i think it's amazing that
we're talking about lists because
i had absolutely no intention of talking
about this but
that this white board up here is
actually drawn uh
with a program called my paint and my
paint which i'm showing here on the top
left menu bar you can't really see it
but it says my paint up there in really
small text
and my paint is actually a derivative of
gimp
um so i don't know if you've seen the oh
look at you getting that program right
nice yeah i remember things which is the
new image manipulation program
have you seen the fork of that well this
is a fork of it
well so there's a fork of it to like
name it something slightly less sort of
offensive yeah
and they've actually fleshed it out
quite fully and it was really nice just
that's cool no i haven't yeah i'll send
you a link
yeah it's it's pretty cool i really like
the uh the pill
pillow divide i don't know if you've
seen that in python but
yeah modern pill is like when you when
you do import pill like the the python
imaging library it actually is pillow
because because oh because of reasons
but anyway okay yeah forks and projects
are fun but
uh the reason i bring up the fact that
this comes from the gimp tree
is that that actually runs the
language that is used for a lot of the
macroing and filtering
is lisp
huh okay it totally is so there's going
to be lisp
powering this stream tonight so it's not
just a theoretical language we are
literally
going to be doing a little bit of list
but just i
you know we're not going to do it in the
editor at least preferably at least at
least let's get through
and i would love to have you yeah this
series next
but oh god i haven't done this been
years i ran away
as a link as a linguist so that was
actually my original background
any kind of communication system whether
it's a coding language
or just some kind of ancient long dead
language with really cool orthography
i just geek out when it looks really
incomprehensible
because i had that sort of someday you
will understand it feeling when i
started to learn arabic where
the script just seemed impenetrable to
me and i was like somebody's going to
understand it
and when i was living in north africa
and reading the newspapers it hit me i
was like
this is that someday and so let's still
kind of has that appeal to me of like
someday
maybe i'll look at that and not be
terrified or be completely lost
because it's really cool-looking but
also in copperheads
awesome about arabic but trust me i ran
away from lisp and i am not looking back
i i look at it and it's incomprehensible
and i look at it now and i go
i'm glad that i could decode that and
don't want to
well fair enough one of the biggest
takeaways from
learning lisp is it will make you a
badass
with um a bad word
the first one it will make you an
awesome person
at recursion um and you will no you will
recurse like none other after
learning lisp like it will cause you to
master it but it is
not fun so anyway um i don't want to
you know if there's list programmers
here you're probably emax people so i'm
on to you
but we still love you thank you for we
still love you thank you for dropping by
okay so let's let's let's let's get
let's get down to sirius work
all right so the first major change we
realized when
we started with c was this declare
line on line five because before in
python we didn't really have to worry
too much about memory memory is really
handled as much as possible by python
but
in c we have to be quite explicit so we
have to declare a type
before we go doing anything and then we
use you know whatever the variable name
is
so um oh no
oh it's okay i don't mean to distract
i'm assassinating no no it's it's
great that's a great
but okay so we have to declare types we
have to be careful about them and the
types that we covered last time were
not not there's not too much in c that
we have to worry about there's basically
just
int care and
float that we're going to worry about
there there's a there's a few
uh there's modified versions of all
these types so
i can have unsigned care
if i want wait what we're going to get
into that later
and i can have i don't think i can have
an unsigned float that wouldn't really
make me much
signed an unsigned makes sense for
integer
what is an unsigned character yeah
because characters can be negative
wait what how
we're not gonna worry about that but
it is um it's it's kind of a remnant of
a much older spec uh partially because
if you if you set the high bit and
most of these types are using two's
complement which we're not we'll go into
two's complement
later um i'm pretty sure with a python
background you've probably never seen a
two's compliment
i have no idea what you're talking about
i'm sorry that's good
i would expect i would be really
surprised i feel like she's totally
hustling me she knows c
like a champ if you knew what that was
so okay that's
that's totally fine so i'm throwing the
glove on uh as you can see
and not the power glove i'm going to i
guess we'll call this the less powerful
glove but
this is this is what we need to get to
um
the white board and yes this is the
two's complement or as
being said in the chat this is the twos
complement
i'm going to switch over since i'm going
to be whiteboarding a little bit i'm
going to switch over to the whiteboard
scene
uh so make this bigger theater mode so i
can see
yeah yeah we're gonna we're gonna use
the integrated view pretty soon but i
think it's a little bit easier to see
for
everybody at home if they're doing that
i'm gonna assume
optimistically you're at home and you're
not at work you
should be doing your own programming no
why are you here i mean that's mean
hi tyler welcome welcome to
no so tyler is my former co-worker okay
he's
an amazing machine learning engineer um
recently has moved on to another company
and i'm really missing being able to
slap chat him during my boring meetings
oh you gotta build another slack right
but he's the person i reach out to with
the kind of panicky situations i was
talking
before before i stream about so when i'm
completely stuck and somebody's
expecting me to make it work and i have
no idea how to make it work i go to
tyler
so he is my encyclopedia of of all the
things
so i'm drawing a wizard's hat um
yes that's tyler if if i could this is
this is
not a good hat but the wizard hat of
machine learning so
now yeah we gotta we we gotta like lean
in you know
just okay so
we can draw and do all the wizardly i
guess
i guess glyphs have to be in elven
there all right so let's just
let's get out oh my gosh here we go
tolkien okay
hey it's part of unicode so it's totally
allowed all right it's basically elder
futhark we're fine
yeah we're totally fine here okay so
um we did a little bit with types uh i
want to talk
let's let's just review really quickly
kind of like what we went over so
we have int which is short for integer
that's our that's our basic integer type
we have care
which is short for care actor
which is our single character type this
is like a single convenient sized
number they eventually managed to
specify it
properly but and we have float which is
our basic
you know floating point
um decimal
type decimal in our normal sense of
decimal as in like 3.14
kind of sense so that's although i'm
actually strongly against this i'm a tao
person so let's
let's let's be let's be tau people about
that
okay um so
jess yes i'm i'm sorry tyler we're gonna
we're gonna try to give her the wizard
hat in in stage no
so it'll take some time okay um so those
are like i need a beard
that's beard is like a state of mind
okay so
all of these types they have different
sizes so let me
um let me just quickly talk about this
this is
eight bits this is typically
we're using c99 and in c99 this is 32
bits
and this i have a really stupid question
oh go ahead you keep saying c99 is that
like a like a standard
4c that happened in 1999 c
in 1999 okay just making sure that i'm
following no you're totally fine
as opposed to like c87
oh wow before i was born okay
yeah like that kind of thing or actually
we could just have c which could go all
the way back to like
k and r type of c which is like
we're not writing there so we're
we're focused on c99 syntax which is is
c99
modern that that's considered modern in
the sea world
oh boy okay
that's uh if you want to get to like
stuff that's moving really fast
um then c like
c plus plus releases way more
they have new specifications way more
often c kind of by its nature is like
more regulated by the un these days so
it's like
it just doesn't it it moves very slowly
like to get something in the standard
and
see by its nature they don't want much
to be in there because changing the
language
like most of c is season tended to be a
very stripped down language by nature
like it's supposed to be just kind of a
bear like this is your machine
and this is your machine on c
download a c so that's that's like
really low level even though
like that's okay so um
that okay so let's that c99 is pretty
much what we're going to be covering
there is a c11 as pointed out in chat
i'm not
we're not going to use any newfangled
stuff like c11
that's none of that okay so um
great then these types actually they do
change from standard to standard so yeah
this is part of why they don't really
like to change it because when they do
change it like a lot of code tends to
break
and that costs a lot of money to fix
so um
i i don't that strophium's comment i
don't and
c plus plus i i i actually am not really
a fan of c plus plus but we'll
we'll oh i feel like that's probably
whenever somebody
even though i don't know cnn i don't
know but whenever somebody says
oh like they say a disparaging comment
about a coding language that's not
javascript i just i feel like those are
probably fighting words
like there's got to be right because i
feel like every time
i've heard many positive things about c
plus plus about
its versatility and oh wow all of its
various applications you've heard a lot
of things about
positivity from c plus i i i need to ask
who you're talking to
we can have that conversation but i
definitely have the cop
okay if python is not making me the best
programmer that ever could be what
should i learn
and i mentioned that i wanted to learn c
and some people said no actually learned
c
plus plus and then there was a whole
nother group of people that said no
learn c sharp and like there's too many
c's
yeah i don't know what's going on we
should really get into that that's a
whole
stream right there but let's all right
we're learning c so let's just learn c
okay um so we have these basic types so
bits we're dealing in bits bit not sure
if you're aware of this
comes from binary digit
it's just a contraction you know we take
the the it and the
actually we might take the i and just
factor it out and we get
a bit all right so bit is a one or a
zero so we're just dealing with regular
binary
so how much is 32 bits how much is eight
bits let's start with the basic type of
character
so a character is eight bits wide
so if i've got eight bits
what's the maximum number i could store
now this is
i'm gonna avoid the trick question here
for a moment but it does get to what you
asked earlier so
this could be a one or a zero there's
eight of these right
okay so hold on hold on i got i got i
got this
so the largest number i could store
possibly is this every one of these
positions is a one
what number is that yeah what number is
that well it's that's what it is
no it's one one one one one
[Laughter]
and that's that's something that's gonna
come up a lot and see like regardless
what your representation
is of the number it's still the same
number it doesn't matter if you're using
a base 2 system
like this binary stuff or if you're
using a base 10 system
or you know a base 16 system which we
typically use
to represent this because base 16 is
nice because it's four of these
so that's the reason we tend to like hex
so this maximum number oops kind of
going a little bit too far down here but
this maximum number can be shown as ff
so ff or all these you know this is
eight ones
um you gotta guess or should we uh
i oh 128. so 128 is actually
seven bits it's actually well 127. this
is
um a little bit of a trick so if i if i
one way to calculate this is i could
imagine that if i add one to this
i've got one one one i was right wait no
it's 256.
okay i heard you say 128 oh so i said
256
earlier when i was just taking a wild
guess and then i tried to math and i
failed math oh okay i'm sorry i didn't
hear that
no you're fine i missed out i missed it
okay but if we look at this and we add
to it one
this is all going to overflow right one
goes here one goes here one goes here
one goes
you know this goes here this goes here
this goes here this goes here
we go into our next digit same way as
just sort of normal decimal math we end
up with this number
and this is really just you know
two to the eighth
so that's 256. so the maximum number
that i could store in here
since this is 256 is all of these things
are ones
and so it's gonna be 256 minus one so my
largest number that i can have
if it was unsigned is 255. so this is
zero counts yeah zero counts so that's
exactly
um not to mention the fact that it would
yeah so if we
didn't include zero then yes we could
put 256 there but
by convention we start from zero but
they're like 256
numbers yes there's 256 numbers anyway
you slice it
there's 256 that you can have 256
combinations i should say
or do i mean permutations oh lord
no no no okay
okay if i flip these bits like if i put
a one or a zero
i've got a total of 256 which is
normally numbered from 0 to 255.
okay so that's neat except that
typically we want to use this last bit
as a sign bit so usually if there's a
one
in this bit that means that the number
is negative
can you repeat that one more time wait
what so
let me clear that okay so i've got my
eight bit wide thing right so it's
here's my
fours and here's my eights so if i chop
that all up
then typically we reserve this last bit
as the sign bit and and that kind of
tells us like
if this is one then the number is
negative
and if this is a zero then the number is
positive
so what why how well because how else
can you signify that this number is
negative
uh making it bigger doesn't seem to make
any sense to me
well if we make it bigger like if we add
another bit here
then we have a 9-bit architecture no
i i guess the way the way that i'm i'm
i'm trying to express is that if we had
zeros
first and i guess this is this is
an assumption but i'm guessing we're
reading from right yes
i mean left to right oh shoot i'm why am
i reading right now uh the
the funny thing about left to right
right to left is actually that's a big
fight in the chip community
so that gets into the way you read it is
not really standard either there's this
thing called little indian
and big indian and this is
left to right and this
is right to left so
um you're not wrong to be confused about
that
but we're that we're not going to get
into chip architectures for right now so
i'm going to be following the convention
of big endian which is really handy
for while we're teaching because it's
the way we write numbers right you know
if we if we write a normal number like a
million
we put the big part over here on the
left
right so the more that we add to the
left indicates an increase in size
yes so how this is a bigger yes
so even though that's the inverse of
like cartesian coordinates and that
throws all of my poor little baby
elementary school math math students off
but
when when we are increasing by moving to
the left
how does that somehow translate to
having
right if you think about it like moving
to the left indicates an increase in
negative so i've had a lot of
instruction but why then when our
our mo our left most bit is
one how are we going cartesian with this
that suddenly it's negative
or like i feel like my students i feel
like i should go apologize to all them
for being like it's okay you'll get it
like
no it it's okay you'll get it
sorry you totally set that up
so why do we choose this bit is
basically what you're asking why don't
we why are we choosing this largest bit
instead of this bit so like if i was
writing this as a normal number like you
know
one two three four five six seven eight
then this is the least important number
right
yes if that's like if you're saying
that's the ones place then yeah yes
one's place so i'm just writing it as a
normal number so
one's place that's a good that's a good
name for it
okay and this is the most
important number
yes but somehow now we have a negative
that means negative well oh because we
put this can i just think of it like
that's what sign is
that's exactly kind of why we do it so
if we were going to make this number
negative where do we normally write it
all right fair enough that actually
makes sense okay all right
so it's like people have lost their mind
but it's one of those things like the
minute you start looking at binary like
everyone just sort of like oh my god i
don't know ah you know but
no no no no they they borrowed this from
sort of like how we normally do math
so um that's great so we would typically
put that here i mean it doesn't really
matter to the computer whether we put it
as long as we all accept the same
convention so we can put it on the left
or we can put it all the way on the
right
but we need that indication yeah we need
we need to
so by convention it's typically here
because that's where a normal sign would
show up anyway
um in a regular number and when i'm
doing this number and by the way we
typically break on threes when we're
doing our thousand separator in
the u.s world then um
it's very fun when you're talking to
like your european friends and they're
like
doing that and then oh with the periods
yeah and then they do that and then
you're like
no no no you only confused me when i
played pokemon
and i thought i had so much money
so okay um so basically
this um this sign bit is was typically
reserved in the original
um kind of architecture so that meant
that how many bits were available to
actually represent a number
seven yes so if i have this is the sign
and i have this as my number which is
seven bit then
what's my maximum number that i could
store in seven bits
now we're saying 127 exactly so here's
my
this would be the biggest number is
everything is a one and
we would just calculate this we could we
could add one to it and then that'd be
the same as
this thing which is you know that
basically that thing minus one is your
127.
okay now this led to a little bit of a
logic problem
when we were dealing when we were first
building computers and
the problem with this is if i just use
this bit
as the sign like i've got you know this
thing could be a zero
means it's positive so we're going to
adopt a convention
and one means it's negative
that sounds good right yep
well unfortunately that creates a new
problem which is what do i do
with negative zero versus positive zero
but what zero doesn't have a sign
uh why not it's right here well
we just said that's the sign bit so if i
set all these other bits
to zero and i put a one in front of it
i've just written negative zero
but
what okay hold on i'm i'm yeah we just
processing yes this seems like this
seems like a problem
not of reality and more of kind of like
convention and semantics well if we had
i mean what other convention could we
adopt
to indicate sign i mean so so no it
makes sense to have like i mean we've
got to burn a big sign
but we can say that negative zero equals
positive zero
and that they're the same okay if we did
that then we would probably have to
increase the number of logic gates we
use on the board massively
because now we have to deal with a
register a memory location all of the
parts that make up a computer could
either have
positive zeros or negative zeros and
those are still the same
so even though this bit pattern is zero
this bit pattern
of all zeros is also zero
so i would have to if i was building
this in logic i would have to say
this bit doesn't matter if all of these
are zero
otherwise this bit matters and this is
you know do certain things and then
otherwise do this and then you know we
have to be careful so
suddenly you're building like a lot like
you're you're adding a massive number of
logic gates
so we could deal with this convention of
negative zero versus positive zero
but that's that that's a little scary
when you're like
implementing this have you seen like
these like old school logic gates
i have not but i would love to okay so
like this is a knot
and this is an and yes yes yes yes okay
actually i have a little app on my phone
that is all of this trying to teach me
to like read
circuit diagrams it was really cute and
back in the day
we had to actually like do this right
you know i mean computers
still work in terms of these logic gates
even though i mean
nand gates became pretty popular because
you could do pretty much everything if
you were using a nand but
um so yeah this is exactly what
strophium is
is alluding to in the chat so what do we
do with this negative zero well
another thing that we could do is we
could just avoid this situation
how how do you avoid that well we avoid
the situation
but um oh uh yeah sure
uh now yeah don't mind uh no problem
um chat i'm just gonna chat with you for
a minute uh give me one sec
sorry friends i'll be right back and
i'll meet myself on discord
interrupt no please go right ahead
um so we have a we have some dog walking
that has to happen
so um all right well i'm just gonna go
back here and show you this wonderful
tool in the meantime
because it's totally awesome actually
you know what i can while we
have this moment i can totally show you
this thing which i think is super cool
and i really can't wait to get going
with it
and this is not we're going to be
literally doing bits
very soon and i'm very excited about all
that and
this is um this is kind of fun because
these are your
you know sort of data pins
a little bit closer um so
we have this is a pretty advanced chip
uh so we have like
some and for those of you that missed it
earlier this is
the uh the nine axis um chip so we have
magneto meter
we can really tell which way something's
pointing so if we wanted to take say
this power glove and we wanted to make
it like
really work awesome yes by the way uh
miss sagittarius this is an adafruit
part
and no they did not sponsor me i had to
buy this thing
i think adafruit is super cool um
but i'm not on their payroll in any way
shape or fashion
so um but you know what's really nice
about all this is like you know for
somebody with my
meager soldering skills you don't have
to really
like get get into this too much so if we
kind of come in here a little bit closer
and that is what we want
then you can see all these like really
fine pins that are on this board
like i am i suck at soldering
so binding this chip would be like a
nightmare to me so
are you back did i hear you
oh yeah you are back yes yes yes sorry i
didn't want to interrupt no no it's fine
i just
got a little carried away with the uh
when when dogs need to go out
hydra no that's that's hustle
or disaster happens so all right so
let me um let me just kind of wrap this
part up which is that
basically what we did was we wanted to
avoid this situation of negative zero
and positive zero
so we adopted another can and we didn't
want to double the number of gates to
deal with
all of this stuff logic gates on the
board so
instead what we did was we adopted this
kind of
a little bit crazy convention so we
still keep the notion that this is kind
of like the sign bit
but now it's in quotes because
it's it's sort of a sign and the way we
calculate this bit
is we basically invert all of this stuff
what wait right
it's like that moment of like every time
i learn something new my brain's first
oh
totally hold on processing
that's the pull the rug out
[Laughter]
um basically what we want to do is we
want to have our number so before i was
trying to say like okay let's go from
127
to you know negative 127.
and that left the problem here in the
middle that we had this zero and then we
go over here and we have negative zero
which we don't want
well why don't we just throw out
negative zero because
nobody really wants that
and that leaves us kind of the question
of like where do we tack it on and
that's um this by the way was not at all
what i was planning on talking about
tonight so i apologize
rabbit holes are the best though we've
completely gone down the rabbit hole at
this point but
um basically we can stick it on one end
or the other
so we can say all right this way you can
go to 128
and that way you can go to negative 127
or
this way you can leave it at oops i'm
totally off my screen at this point
so this way you can go to 127
and that way you could go to negative
128. so those are basically our two
choices
how do you choose and the way we choose
is we just sort of slide everything over
so joking no that it's a little bit more
complicated than that but
just because we want normal math to work
because like if we if we take one of
these things
and we want to reuse the same circuits
so like
if we instead of just encoding it like
we
we would naively which is we just use
this this bit to represent the sign
then you know one would look like this
you know all those zeros
and if i wanted negative one we would
think that this would be the one right
yes okay well this
ends up kind of violating math a bit
because what happens when i add a
negative number with a positive number
it depends on the size of the numbers if
i do like
five right exactly if i do five plus
negative two if i do five plus three
negative seven
i mean this is going to wrap into the
negative space this is gonna
stay in the positive space if i invert
that
and i do a minus the minus a negative
then
really i'm doing the same thing as
adding so this this all kind of like i
want to keep it so that all of this
stuff sort of works
like by default and that's basically
the gist of why we're going to do
something crazy
what we're going to this is all crazy
yeah this is all this is actually how
the computer really works
so i think the thing that i'm struggling
with is it
i did a shift one way or another but
that
that you broke is there no standard
oh i'm sorry so i guess describing i i
love
of course yes i'm my math my math brain
is
all on board with getting rid of the
negative zero because that made me sad
in the first place
but and and and extending the range in
either
positive or negative direction makes a
lot of sense sure
however i feel like should it not be
standardized
it is right other okay so it's it's not
that it's
user's choice it's that abstraction was
made
this is the decision kind of like back
in the 70s
okay um and basically what they ended up
doing in order to preserve all of these
operations that i'm showing you
i'm doing like kind of the fast version
of this like the full lecture would be
really complicated but
um it's not too much worse than what
you're seeing right now but
you know i don't want to go into that
level of detail but basically what
they're going to do
is they're going to flip all of these
bits and if you do that
then your basic properties work fine so
this stuff that i was showing down here
like five plus negative two
five plus minus seven all that stuff
they'll work with just a normal add
like if i just keep my normal ad rules
then flipping all these bits sort of
makes that work
and when you say flip yes are you saying
invert
or are you saying reflection i don't
know what
that means like are you saying mirror it
like like
you are flipping it over a horizontal or
a vertical
axis or are you saying invert each bit
like do the zeros becomes do do the
zeros become
ones or does the number become mirrored
uh the zeros become ones so it's
inverted
yes so to get a sign like say i want to
flip this thing
then basically so it's called the two's
complement that we're talking about
and the way it works i mean
i can talk about it at the bit level
like we're talking there's there's some
nice logic gate properties but
it's a lot easier to calculate if you
just look at like say you have a number
and we're going to call it num
it could be it could be any number right
this could be like five or this could be
seven but it's gonna be something
positive
if we wanna get the negative version of
it
then the way we choose complement and
avoid this like you know zero thing and
all that range stuff
is we basically take two to whatever
power this is
like whatever position this is so this
is like position zero
one two three four five
six seven and so this would be the
eighth
location which is not part of this
number but
that's how many bits i have total if i
count them right so
that's eight right four and four okay um
so i take two to that power which would
be two to the eighth
and i subtract whatever this number is
okay so 28 minus five so one two
not not two not twenty eight two two
fifty six two eight
yeah it's not seven 256. so 256 minus
five 251.
yes and that is actually what's
represented what's nice about this
number
is i can tell because it's a high number
it's anything above 128
well 127 or
anything greater than 127
has this last bit flipped so
by convention those are going to be
negative numbers so i can tell right now
that this is a negative
negative five if we did the math right
okay okay and that's called the two's
complement and complement in like the
sense that this
five and negative this 251 and this five
are
complements of each other in that they
both add up to
two to the eighth
say that one more time so we we call
these complements of each other
complements these which two things are
the complement of each other
um five and it's
two's complement is 251 at
doing it the way we just calculated if
we add these together
we get 256
right okay all right yes i'm following
which is to the eighth which is if i
unwrap it it's you know
there's our two to the eighth minus five
so this is this is probably a really
silly way of thinking about it but
visually
what what i'm imagining is when you
first were describing
we have these these kind of eight bits
and as we're sort of progressing and
we're adding ones things are getting
bigger right so it's almost like a
number
but as we move to the left things get
bigger yeah well
now because of the negatives they've
decided to almost split it in the middle
yeah and so so you have kind of mirrored
have eight
yep yeah that wasn't a compliment right
and then we avoid that negative zero
thing
yes okay that makes actually i i think i
understand that
and it actually works so i can i can add
these numbers together and you know
it'll
stay in the right thing so if i have
something like you know
251 and you know i add it to
you know three
it's gonna stay negative
right so that that's going to end up
being like 254
which if i flip that to two's complement
which is 256
minus 254 i end up with this is really
the representation of negative two
negative two yeah which is cool so
that's the same as i took this 251 was
negative 5.
if i add 3 to it i end up with math
working
and that's why they did it oh that is so
cool all right okay i think my brain is
i'm like tenuously understanding yes
i think it requires a deeper lecture i'm
sorry about that we're
trying to no this is really fascinating
because i mean if you
mathematical problem of of how do you
implement the full range of of well not
full but like
you know a limited set of both positive
and negative numbers without duplicating
the split
yes the split point exactly and that's
interesting
the other constraint is we want math to
still work
well yeah and so what who ah people are
saying otherwise we would have to double
our math unit like the math unit on the
chip would have to have
how to deal with positive numbers how to
deal with negative numbers how to deal
with one positive and one negative how
to deal
with one negative and one positive right
which would that would increase the
amount of logic on the chip
a lot but yeah that sounds like my
approach in python of just try
accepting everything no it's just fine
in python but you know like
we're talking about the metal like
that's gonna directly turn into cost
right if we make the logic that
complicated
engineering time is going to go up chip
failures are going to go way up you know
bugs are going to go way up it's
you're talking about i mean chip fabs
you're usually talking millions and
millions i mean this is
very expensive stuff so they had a big
incentive to try to get this right
so you know this reminds me a lot of
when i started first playing minecraft
and
you know i i think it's a wonderful game
it's beautiful
and you know i was so excited to just
collect random
resources and and build a house and not
die
and of course you know this was many
many years ago i haven't played in years
but
went and googled minecraft and lo and
behold people have built computers in it
and i'm sitting there like
okay i barely am surviving the night i
think
farm i've got some sheep i'm really
proud of myself and someone's built a
computer
and so i think that's almost what it
what this reminds me of is kind of that
i'm really proud of myself for sort of
writing
writing in python but underneath it is
this very
very complex but fascinating underlayer
of well we're getting closer to the
metal now yeah i mean this is no this is
this is this is really interesting
because when you first intro
plus or minus zero problem i've been
thinking about it as you've been talking
like
how could you fix this how could you fix
this right over and over in my head how
do you how do you get away from this
problem of doubling the zero
and so it's really fascinating to
consider instead
well basically a number line but but
using sort of your your
bit storage like a number line and
splitting it in the middle and having
reflective that's really interesting
right but we keep the low numbers
acting the way numbers work right so
everything that's
less than 128 which basically is all the
stuff that doesn't have
this you know this top bit set
um it works the way we expect it to work
so
like 0 to 127 is exactly like
how you would expect it to be stored in
memory so you know
one would be shown as all zeros and a
one
two would be shown as all zeros and
this gets a one and that gets a zero and
so on i should you know really clear
this if we're gonna do that but
do me a favor and do do a positive
number
minus a negative number because i'm
wondering like this this is fascinating
and i keep coming back
these students that i've tutored in math
who are elementary school students
deeply struggling with the idea of a
negative number
and i almost wish that we taught
computer science maybe like way earlier
because i think this
actually would sort of make a lot more
sense
is being able to show them
that i i don't know how to explain it
like it's it's
yeah i usually go with a number line one
yeah i would do it graphically probably
to somebody who
hasn't i mean but then it's also like
this idea
of minus a negative becoming a positive
just
that's what i learned as a heuristic
yeah
right is that you know you take the two
minuses
but it's it's quite interesting that
when you convert that to
their respective i guess bits or
whatever
that if at least if my brain did it
correctly in my head
it it works oh you want that as a binary
example i'm sorry
[Laughter]
yeah i got a little animation you can
take this minus and you can kind of move
it over here and then it moves on top of
here and you get a plus
help me with elementary school math i'm
sorry i totally misunderstood your
question
i should have specified i'm sorry okay
so i'll take the same example because i
mean i already wrote it out so i was
doing
five minus minus three um so
the first problem that i have is i have
to represent these in binary
right so right five is actually a
you know it's a four plus a one and
three
is really the minus version of you know
a one a two plus a one these are in
powers of two
so i'm doing like one way of converting
to binary which is going to be
we need a one in the four bit and we
need a
one in the one bit so like if i've got
you know if this is my number so five
fortunately like so this is my this is
my
one placeholder and this is my
two placeholder and this is my four
placeholder
then this is going to be a one in the
four
plus a one in the ones digit and i put
those together
and i end up with a five so there's
there's my five representation in binary
this can also be thought of this is the
two to the zero place this is the two to
the one
place this is the two to the two place
this is the two to the three place
okay that one makes more sense yeah well
this is more analogous to probably how
you think about normal numbers right if
i do one two three four then this is
really
the ones digit so but we're in base ten
so this is ten to the zero
and this is wait no that's four is not
ten to the zero
well no no this this place sorry that
just where the four is occupied
is oh i'm sorry okay yes yes one place
tenths place ten to the one
this would be ten to the ones place this
would be ten to the two's place this
would be ten to the three's place
this works for any arbitrary base by the
way you you take the base
and you take the the num you know the
the exponent is basically how many
digits it is from
the zero so right so if i take that as
like you know
this number could be written as one
times
i'll write it out like ten to the three
plus
two times ten to the two
plus three times
ten to the three well sorry whoops ten
to the one
plus four times 10 to the 0.
okay and if i do that i end up with
1234.
still good yes yes so using
that representation we can we can do
that with base 2. so this is this is
base 10
or decimal which is the reason why that
format specifier is a d
percent b okay yeah
versus like this thing over here which
i'm composing out of powers of two
so this is two to the zero why why are
we using two because then we can our
logic gates are going to be minimalistic
i mean that's kind of the reason
we started with binary in the first
place
we we could try to build a computer on
base 10 but
that's a lot of circuits that i can't
solder that much
okay so um converting this five
over to binary is sort of the matter of
like which powers of two
add up to making five
so in this case it's it's a four
plus you know a one mm-hmm so it's like
a
power of two power of yeah this is the
power of two digit plus the power of
zero digit
zero yeah so my binary representation of
five is 101.
okay so if i do that minus three
how would i get 3 normally well as
powers of 2 that's a 2 to the 1
plus a 2 to the zero right right which
would be this is just 1 1.
this is 1 and that's a 1. we're going to
put a 1 there so
3 is going to be 1 1 and
now i need to do this two's complement
business
so working in the decimal space i would
just do 256
if we're working in 8-bit numbers
i do 2 to the 8th which is really
also known as 256 and i subtract
3 from it and i end up with 253
and if i represent that it could be
represented the way that strophium
actually mentions
in the chat so all i have to do is flip
all these bits and subtract one
so um right so basically
that's going to be 0 0 0 this would be
positive 3 would be 0
0 1 1 and if i just flip these bits
and i subtract 1 from it then
i should end up with that doesn't look
right
uh there's two zeros at the end
if you're well that's what it is if i
don't do the subtraction right
yes that's just flipping all the bits um
so i have to get
253
which is
wow arithmetic huh sorry i really put
you on the spot i appreciate it
no it's okay i mean i would i normally
don't do it this way so i'm used to
just calculating what is 253 and 253 is
a 128 plus you know a 64
plus which is actually all of these
things
um and if we just
check our math then
this uh
it is minus one right strophium doing it
this way
so i would just have to do 0 1 0.
so i think that's it but um quick way to
do that
i mean well hey we got c we can why
don't we
have c do it for us
did i lose you oh no i'm here sorry i
thought you were
explaining how we make c do that for us
oh no we're we're beyond
that not now we're coding oh boy all
right
so we're going back from okay yep yep
yeah i mean so all we need to do is we
just need to be able to
output binary um
so we'd have to code that whole routine
wouldn't we
uh so rather than do that let me just
check the
format i was i was just working a lot in
um
in uh python so i forgot the format
specifier for binary and um
in c so i'm just looking at the printf
man page
and let's see
this thing so quick question yep um
we've been asked by the chat if uh these
videos have been recorded at all
because folks want to kind of start from
the beginning and follow along uh
yes i need to talk to you about your
feelings on
posting them i'm fine i'm really
you're good i've i've been very well
behaved i have not
you've been the one to actually swear
not me okay
i think i've i've behaved unfortunately
that word which i'm not gonna mention is
still tv safe as far as i'm aware
so i think we're okay there definitely
more well behaved than i normally am on
my stream
totally fine no but assuming like you're
okay with all that then
i could post that you're fine of course
okay
um so yes the answer to chat we will put
these on
uh we'll put these on youtube but uh
let's
let's get through the rest of the lesson
okay um so i feel like i'm gonna start
having to like solder something we're
just going so deep i love it
i love it but i'm like should i should i
like we could have a
second let's do this why don't we
um let's build a computer i'm gonna i'm
gonna just cheat and
punt on it by figuring that we can
use hexadecimal because if i
use hexadecimal like in the martian
then okay this is we're getting 32-bit
math here but
um i i'm jumping a little bit ahead of
what i was going to say
but unfortunately but the important part
is going to be these last two digits
which correspond to the
to eight bits so there's the answer
right there which is fd
and d uh borrowing i just wanted to
check the math because i really haven't
done this in c
in a while but um so this is
normally written as 0x fd i'll
write it in uppercase um hex and f
corresponds to one one one and
d is a couple behind it right because d
e f
so it which is our minus three
so um so e would correspond just just
to break this out because i'm kind of
talking over it but
um if f is correspond to here let me
clear all this
if f is 1 1 1 1 e
is one one one zero then
d is one one zero one
so that's it why
i'm sorry so i so i went with the
classic just alphabet cipher right so
i'm like okay if i'm gonna
if i'm sitting down and and using all of
the things that you've taught me and i
want to encode the alphabet i would
think i would just kind of use you know
like
all zeros is maybe a i don't know all
zeros and then
one is maybe like b and so how how have
we gotten
what is the equivalent of four four ones
which is like what two to the four
two to the three cetera is somehow f oh
because that's
hexadecimal if i wrote the whole uh the
answer to that
is actually in the definition of what
hexadecimal is
so that's basically by the way thank you
very much that's that's my handwritten
answer
who questions about like
why certain memory things are happening
i just like
and this poor child doesn't like even
know what that is or know why i'm
telling him that
but thanks to you and our first c stream
i'm like oh
yeah it's probably just because of hex
that's like
oh i don't know really but it's memory
thing so probably
okay so well here we'll we'll just count
it up i mean this is literally like
okay so this is all zeros i'm just gonna
stop the slashes for a second this is
one this is i'm just counting all of our
binary our four bits of binary
right zero to the one yeah okay yep yep
i'm following
yeah and then zero one to this and it
goes to the next digit so
zero one zero zero zero i add another
one here so
zero one zero it's not that hard i add
another one here it overflows zero
one one 0. i add another one here
0 1 1 1.
i add another one here i get 1 see
there's our 8th bit this is actually our
sign bit by the way
in our 8 bit example
but we'll just keep going so this is
this follows
from here on it follows exactly the same
pattern it was
down here so this was you know one zero
zero one one zero one zero
one zero one one one one
zero zero
and if i keep going up from there i get
my one
my one o and my one one okay so i wrote
this correctly
this is d is this thing
right uh-huh so
why are we using hexadecimal why are we
adding these extra digits to our number
line
because if i do this i end up so with
these
16 they're not called digits but let's
call them hex
sits
[Laughter]
okay even though this is uh has a funny
history because if we do that
in latin and
yes yes let's not do it in life let's
not do that
i've got five years of latin under my
belly
teenage uh so uh it turns out we flip
over to the greek and we use half
secret instead of the other word
and um yeah so why do we use hex well
it's because
this very quickly represents four binary
digits
right one of these numbers from the hex
world
corresponds to four of these binary
numbers
what what i know sorry i just like you
say things sometimes and it's gonna
i don't know if this is just like the
lack of caffeine that happens at 9 00 pm
at night or no rain
but it's like i'm sorry what did you
just say there's a
that is the important part so i'm just
going to write a few of these so
let's just do if we're if we're writing
out four binary digits
okay so
i mean maybe it's better if i actually
just do a whole chart
well if we're going to go that much the
whiteboard
sorry chad i didn't i didn't i didn't
plan on getting this far
down so i will i will i will tell you
this as a
as a consolation
this is unfortunately a side effect of
teaching
and i found this out the hard way in
graduates
when i was in my stellar astrophysic
we're discussing how nuclear fusion in
the in the
stars and i kept just asking questions
okay well yep
i understand that but you know
how does that happen and the teacher
would explain i'm like okay
but how does that happen and i kept
asking and asking finally my teacher
kind of like loses it a little bit and
is like we don't know
okay don't know that's like the
sub-sub-sub-atomic level and we don't
know okay we just don't
i was like oh i'm sorry oh
that's just that's i i i i we can know
with the subject everything is from your
first principles like
now you're real ones like that's
i'm uh so i'm a registered nuclear
physicist
department oh so we we absolutely
can know and i spent a good little chunk
of my life
knowing exactly what you were just
talking about i mean we were getting
into like quantum chromodynamics so like
like sort of the forefront of the
forefront and like
at one point though i'm probably on one
of your lists of people to watch
because poor poor poor quasi baby jess
was like googling all this stuff being
like fine if my teacher won't tell me
i'm gonna learn myself
and like ended up on some like
restricted website with all these alerts
from like the us government being like
this is protected and restricted
information like you don't have a
clearance like blah blah blah
it's like i panicked of course as as an
early 20s person because i was like i
just wanted to understand how stars work
and but no so my point was just if ever
i go too deep you can kind of just say
not now and i will i will pause the
brain
but okay generally speaking it it helps
me a lot
the the more fundamental we start
because then
that knowledge is really great and i can
build from that but that's just
it's how my brain works so if ever
you're like wow i don't want to
spend all this time talking about binary
like just wait i mean if you don't mind
the fact that i didn't prepare this part
of the lecture
this is awesome are you kidding me like
i've always wanted to learn binary and i
was wondering
how loaf bone in chat could whip it out
so fast when we were doing puzzles and
stuff
and now this makes sense yeah math the
math makes my brain happy
no that that's fine i mean so basically
i'm just writing a chart here
like this is just normal decimal numbers
here on the on the left
and this is four binary digits
in the middle and what would this be in
hex
so here in this four bit representation
we're seeing like all of the possible
combinations of four bits right
so we're restrict so so why have we gone
somehow from eight bit to four bit and
i'm sorry if that's a stupid question
just like we used to have eight and now
we have four let's stay with four for a
moment
is that where hex comes from because
honestly like exactly where it comes
from
okay that's exactly what i'm showing you
we're limited in terms of our memory and
limited no no no no it's the same amount
of memory so
the number of bits doesn't change no
matter what the representation is
but that what we want is i've just
written if we do this
four bit thing this gets kind of obtuse
by the time i'm
talking about like do you really want to
write out like 101 i mean that's a lot
of like
screen real estate like what if i do a
32-bit number i mean that's
oh lord this is just four bits hold on i
can barely handle eight let's talk
i mean so like if i if i here's like
eight bits
here's like you know 12 bits and here's
16 bits and
i'm only halfway there oh man
we're halfway there
living all the binary prayers
i mean we're just like this i'm writing
this stuff all day i'm singing bon jovi
at this point like this
is this is crazy
[Laughter]
so all right wait wait wait hold on
sorry
i got a little carried away there
i was only halfway there on 16 bits
right and then by the time i'm getting
to 32 bits with another 16 bits
i've written a lot of freaking digits
now i'm terrified of 64.
like yeah like you try to write 128 bits
like you're going to be writing bits all
day i mean this this whole thing is
going to go
crazy so that's basically the problem
so um i want a compact representation
of this thing right so that when i'm
actually looking at
like 32 bits which is you know a lot of
processors are 32 bits
these days 64 bits when i'm looking at
that i don't want to see all this
right i mean this is like going to be a
crazy amount of ones you're going to be
like looking like is that a one
one one zero zero one one zero one two i
mean i'll be saying that all day and
we we won't even know if we said it
right like i could totally have flipped
the one
in the middle there somewhere and it's
very error prone right
oh boy okay so so so how do we solve
that
like i mean you're a linguist we need a
more compact representation this is a
very non-compact representation
right and i'm guessing the answer is to
somehow represents
four bits because that's what you
circled over there but yeah i just i
guess
i don't understand how we get from happy
math land which makes a lot of sense to
me where
you know the ones that the binary
actually makes sense for the first time
in my life like i get that
and now bits aren't scary and they're
not just random numbers
it actually makes sense but when you
turn
instead to having say
you know a codex for for
english language orthography your a's
and your b's and your c's et cetera
i still don't understand why it's not
just a basic alphabet cipher why we
don't just say well it is an alphabet
cipher
we we take this thing over here
you know where i this is one zero right
well well actually this is a ten because
we're in base we're in base ten this is
decimal
but i overflowed when i went from nine
to ten right i moved to the next
position
yes okay that is not what happens over
here on the binary side
right i'm overflowing every single line
i mean
you're yeah i mean because because you
can only count by one essentially so
every
every every even step yeah every other
line i'm overflowing so
so that means that this representation
and plus from a symbol perspective like
you just mentioned this is a lot of
uh symbols to convey very little
information right i'm only using a one
and a zero
so my entire cipher is composed of ones
and zeros doing it this way
but how can i compactify that
and still preserve this notion that it
overflows
position the way that i normally think
like so here
it overflows from nine to ten it goes to
the next digit right
okay yes but that's not what happens in
binary because
it would overflow up here on the 15 line
okay right because the 15 line 15 in
decimal
corresponds to 1 1 1 1. so if i add one
more here
i end up with one zero zero zero zero
right i overflow to the next position
right and we we're limiting ourselves to
four bits right
that's so that's what this is like if i
only want to use how many symbols do i
have on the left
one through fifteen i've got 16 symbols
right
right corresponding exactly to 4 bits
so that's exactly why we invented
hexadecimal so all we had to do was
extend our numbering system this was the
9 line
and all i had to do was add in a symbol
that represented 10
which was this a and then i can add in b
c d e f
and this is the lot this corresponds to
15 because after that
i go to one zero
okay do you see that so i'm talking
about like
how do we correspond to four binary
digits
four binary digits is represented by 16
symbols
so we just named these symbols that
normally overflow
we we just moved we named them like this
stuff over here we just started using
letters a through f
huh okay so so this is funny story right
this is interesting is that i wrote a
a hex to whatever normal people number
conversion sure um because
when the hubble space telus returns your
observations to you
it returns it to you as observation
underscore a hexadecimal
number or whatever and so i was dealing
with random letters the number isn't
totally confusing so i remember kind of
some of this when i was trying to figure
out how it works so i could convert it
to decimal
and have like oh this is you know my my
98th galaxy that i was looking at
but this is some weird convoluted string
of numbers and letters
um i guess so
i think i think the thing that is
tripping me up to be honest is that
we've gone from
a system that made mathematical sense
where
you know you are almost talking about
the the
place value of of a number by
by moving from right to left yes and
representing
various various numbers increasing in
their
their absolute value as you move right
to left that made sense to me
and then of course as we try to
mathematically have a representation
for characters we somehow decided to
like
truncate things at nine which makes
intuitive sense
because really a 10 is just a one and a
zero
but that's not how it works in the
binary because
things are kind of stacked so that's
where i'm sort of i'm getting a little
bit tripped up oh no that that's fine
and actually i'm going to go back to
strophe
a comment that's trophy made because
this is actually what it comes from why
do you imagine if your fingers heading
no and that that's actually that's
important because that's actually where
we get counting from
why did we choose 10 symbols right
i mean that's arbitrary right yeah we
chose it that literally has to do
with call them digits
what are your digits yeah
it's it's it's one of the sort of
hilarious you know
pub arguments between a math
mathematician and a linguist is like
you know oh worthy you know mathematics
is the basis of
of all things linguists like well why
why do you call them digits
right it's like it's it's a convention i
haven't heard that but i need to go to
the pubs that you're in
there's there's no question from hearing
this because
i would love to go to a pub like that
well especially when like you know
having once been a linguist and sort of
converted into more of a math well it's
a long story but anyway being both
it's it's fascinating but it is entirely
convention
and so you know there are lots of
amazing
science fiction novels that cover what
happens if we
encounter a species that has decided on
base
8 base 12 base 11 like how do we deal
with that and how do we
communicate whether we like it or not
math and language are
inextricably linked and so
no no this is important yeah this is not
theoretical
like we call them digits for a reason i
mean they were the digits on our fingers
we learned to count with our fingers we
learned to do our math with our fingers
if you chose to count with your toes as
well
like say the mayans did
what base would you choose for your
numbering system
i thought mine's okay so again i sorry
sorry chad
i was my my my my linguistics
so um it's not hypothetical about like
another species that's where base 12. no
i'm pretty sure they're base twenty are
they base twenty okay no no no then
that's my mystery i
vague they we're talking like over a
decade
i just wanna make sure i got the right
culture i 100 i know that this actually
came up in my
history of math course i haven't looked
back so that's cool
because i know there's one sort of like
proto proto-south american culture that
that did base i thought it was base 12
or base 16.
but it's that's that makes a lot of
sense to have base 20 then
yeah i i remember i'm pretty sure it was
um
the mayans but it could be another
culture in that in
in that area but it was it's called
vegesimal i mean because literally
you're
you know decimal is you know we're
borrowing the the latin stem here
um so staying with latin we can go
vegetable
yeah we've got we've got chat following
and that
we can we can count with our this is
just using our fingers
because we got 10 of them usually in
most cases
and this is using fingers and toes
right so there's no real reason why we
chose a particular base other than
we just happen to have that many digits
on our hand so
you know when we're talking about binary
there was something else going on which
is the number of logic gates that we had
to operate on
right because we didn't use decimal
because it would
increase the number of logic gates quite
a lot and
when we were building on this base two
uh
logic we ended up saying like okay
this this is gonna get really messy
because base two does not naturally
divide into base ten
right i mean despite the fact that ten's
an even number like there isn't
how many binary digits would be in a
base 10 number
and the answer by the way is on your
screen oh well i was trying to do it in
my head you could do it in your head but
i mean it's right here on
the 10 line yeah right so this 1010 is
the bit pattern for 10.
but that means that i'm wasting a bunch
of bits because
i'm never going to set this thing to
like 1 1
1 0 this would be an illegal bit pattern
because
that's more than 10.
right okay so that's that's kind of why
they said okay well
the real problem here is the fact that
computers don't if computers are
counting on their fingers they only have
one finger
well you know what computers uh okay
well gg i win there we go
i think so okay so this is my quant so
strophean says this is why
quantum computing is so strong since
transistors can only hold on off states
binary values end up being these long
strings
the more values you can represent in
this digit all of a sudden your
operations just get way faster
so sophie munoz should have i think
that's a stream conversation about
quantum computing because my favorite
class in in graduate school was quantum
mechanics and that's the physics that
makes me happy
that feels very very very far away from
what i am doing right now we should we
should we should talk about that
yeah but definitely getting far from
two's compliment but
um just to fault line's uh comment
right above it yeah the same number
is represented it's the same number it
doesn't really matter what your
representation system is
right so in the case where
i was doing um if i'm doing binary or if
i'm doing hexadecimal or if i'm doing
whatever
i mean like this number that i think of
as
five in ordinary terms corresponds to
you know one zero one two to the two
plus two to the zero
so i need i need a one in the two bit
and i need a z a one in the zero bit so
if i put that out as a series of bits
then this would turn into
well this would be a one in four bits
zero one zero one right
yeah this this would be a zero in the
one bit
it'd be a one in the two bit and a zero
here so this would correspond to five
but
these two representations both mean the
same number of things i mean like if i
was counting
triangles
it's that many triangles right
i think i think i'm still kind of um i'm
i'm tripping up on the like the math
makes me happy
like the numbers land that's that's the
happy place
the second we step over and just somehow
represent characters so string string
parts
string string bits in in numbers
i i start to struggle because
it seems very arbitrary to me
why we've decided
on either zero to nine because like
again like like we just talked about
that's a human convention or
that's a very not that's not a human
convention excuse me that's a very like
specific human culture convention right
of going zero to nine and then starting
over
and why not make it some multiple of
of of you know however many letters are
in
i forget i i know a few alphabets so
bear with me like
i think it's 26. we talked about this
earlier 2026 for english i think yes
um yes why not make it some some sort of
like multiple of that
like 13 like why because it's very
arbitrary the second thing you move into
the oh we need to start over when we get
to nine be
a matter of convention unless a matter
of like
so so why is if hexadecimal is the thing
we use
to to be able to represent characters
why did we not pick something that's a
little bit
more rational uh i would i would say
that it
is very rational but the rationality is
entirely based
on understanding hardware theory which
is
not really something we should get into
yeah no worries and that's fine you can
no i mean there's a very rational
reason why they chose binary i mean it
like it it has to do exactly with logic
gates
i mean because they were using two-state
logic gates so you know you can do
things no i mean the
the choice of binary makes sense to me
that's not i guess the choice of
so how do we define hex oh that well i'm
showing you basically we
we the computer is operating on binary
so
because we don't want to write out these
long strings of zeros and ones
we said all right let's just take four
of these things and compact it into a
single digit from zero to f
and that's it so you can think of
hexadecimal
as just a compact representation of four
binary digits
so okay hold on i need to give me one
second here
so that's
did we say that that ended i'm sorry i'm
like having a small
brain fart so that's fine it goes zero
to nine
and then a to f so that's a totally
15 right yep
so well plus 0. that makes sense yes and
that makes sense to me
like 15 i'm sorry not 15 the number the
number of digits
um yeah which would be 0 to 15 in
decimal
right and
okay yeah so if we use that compact
symbol thing
then i can represent using this hex i
can represent four binary digits
at a time with a single symbol
make sense i think so i think i just
don't know why why we didn't just why
did we switch to a then
oh oh like why did we choose a as the
next symbol yeah why didn't you just go
0 to 15. because 15
doesn't fit into a single digit i see
okay so the ideas
take what is represented by four digits
and represent it as a single digit
got you okay in one second i've been
stuck on
i thought um got you okay so
my brain was going down the again
linguist hat
sort of sort of street where
i thought the goal was how do we take
binary and then represent
the english alphabet and i was like this
seems really awesome oh that's
why are we doing a different
conversation right and so
you kept telling me oh we go to nine and
why not just start with a i'm so
confused
that's totally different so much more
sense if we're trying to compress things
yeah i got you okay we're fine we're on
the same page
that's it no no that's totally fine we
we took these four
binaries slow today no it's totally fine
hey you're getting over covid dude
yeah i'm gonna you know that's gonna be
my excuse for you gotta buy for me like
december of this year and be like no i
mean so
like just looking at this thing we we we
can compactly represent
you know four binary digits with one hex
digit
in a single position right so i don't
have to overflow so 15 i could represent
it as 15
or i could represent it as f
right but the whole point is to take the
breadth
of numbers represented by four
bits and have
one digit yeah because otherwise what am
i gonna do when i get to like
you know what do i get what happens when
i get to 16.
so if if 15 corresponds to
i mean we'll do it your way like let's
say we didn't use hex
so so 15 corresponds to one one one one
right
yes okay yes now how are you going to
show 16
0 0 0 1 plus 15.
i mean it's no problem in binary it's
just you know one yeah
i mean that's like yeah we add another
bit but if we're stuck
we're adding another digit because we
invented positional math right
because back in the day we used to do
like this is five
and you know this is three and this is
ten
and this is 50. yeah we're going back
now
old school and this sucked because
what's like l
v x i plus i
i c m
you know like i don't know that's going
to take a while right
that's that's totally how it used to
work back in the day when we chose
arbitrary symbols instead we moved to
positional math and we said
each one of the positions of the digits
by the way yeah that corresponds to yes
it's actually it's funny it's not arabic
it's it's it
like people talk about like arabic
numerals they're not arabic numerals
like
arabic numerals are an entirely
different thing i mean i
i know arabic yeah they don't look at
all like latin numerals but
but we definitely stole the positional
thing from it you know like we were like
oh okay this looks pretty good
because i can actually calculate 15 plus
five
pretty fast right yeah
but if i want to do x v plus v
it's not intuitive yeah i mean i'd have
to know that this is 15 because i'm
already cheating and using positional
math in my head
and i would know that this is v i mean
can you imagine doing a times table in
ancient rome
oh yes okay i've actually so i've had to
do math
in arabic like arabic numerals before
and it's
just as intuitive as it is in in
our our our numeral system um the only
thing that's difficult
is that it's right yes and so for the
longest time
all right the switching is what gets so
i would have like my arabic
back to back and it would always just
throw me a little bit because i would
get so
comfortable reading right to left and
then switching to left to right like
that was the hardest part honestly is
not anything else but
how are we gonna do two times two
oh lord i mean five times five
25 is what is that is that l it's xxv
okay l is 50 i know that i i don't want
to do this i mean this is
like torture like like
v times three v times i i
like i can't believe i got this far
i mean
like imagine learning this in school
poor latin children we know why they
conquered the world
i mean this they have if they can
understand this they could conquer
anything
jesus look at this sometimes it explodes
into three digits sometimes it's two
digits you know this one's bigger than
you know this one that that one even
though this is only two digits but
that's three d
i mean this was a huge advance to stop
doing this
like so so yes that's exactly the reason
why we said no
no we don't want to put 15 as a symbol
because then what what is what number is
this
one one five one one
that doesn't wait i'm sorry are you
saying it are we are we are we
okay so that's a 115 in well no that's
decimal i'm not writing this
i'm using your encoding so let's say
that we didn't use
f right
so this is like one
and then that 15 pattern oh so that's
that's 45.
okay you're translating back to decimal
you don't get to work in decimal the
computer doesn't get to work in decimal
no no you said if i get my weird way of
going
0 to 15 and booting over like base 15.
right no i'm saying i'm writing it your
way i'm not using the symbols a through
f
so a through f are out so i'm going to
okay yes i got you i'm going to do
hexadecimal
but i'm going to go 0 1 2 3
and then i'm going to go 16 10 11 12
13 14 15. and then i'm going to roll
over
to 1 0
and one one and d and then i'm gonna get
to
like down here and it's gonna start
looking kind of crazy
like this is one one o and this is one
one one and this is one one two right
and that was all
fine except how do i know when i look at
this number that it's one one
two with the 12 on the right
and this thing on the left versus it's
one
one two
and this was just a two in this digit
and this was an eleven i mean we're
right back to this row
one zero two that's the same bs that
that sorry excuse me that's the same
stuff that binary has been doing the
entire time though is that like
how do i know that one zero one one is
ten slash eleven and not
one slash eleven or one zero one slash
one it's the same sort of like
i feel like because every single since
there's only
basically since i know that all of the
numbers that are in the base
fit into a single position i
i know that if i write this
unambiguously like if i know that i'm
writing binary
then like i know that this is a one in
the
two to the one place and i know this is
a one
in the two to the zero place yes and i
know that this is a one
in the two to the two place right
because there's
every symbol corresponds to only one
position like
one seven right yes so if i break that
by doing this
now i suddenly have a parsing problem
because like one one five i don't know
if that's
one and a fifteen or if that's
an 11 and a 5.
yeah i mean i i see what you're saying i
guess guess
i i'm i'm i'm being a tiny tiny tiny bit
of a troll
and just so far as like
so much of how we represent semantic
meaning
is convention and so functionally
speaking
there is no different as to whether we
have something
that operates in the sense that written
right there or operates in the way that
we have hex
it's a matter of like convention and
representation of meaning
but i'm really like that's that's that's
like that's i'm going like
super super troll there no i'm not
that's like troll at all
like why are we doing this in the first
place because we got tired of writing
out all the things i mean i could just
write out one triangle for every
thing so how many triangles is this
nine yeah i mean that's nice that i put
it in a nice square for you but
you know i can kind of troll you back
okay i got you 12
13 i'm following so like can't pull one
over me like like this
sucks to read right i mean that was the
whole reason we went with the encoding
in the first place
because we didn't want to write this
right we would much rather write this
out as however many of these freaking
things i just drew you know like so this
was my nine 10 11
12 13. so i would rather write this
because
this is a much more compact
representation of all that
and that's exactly why we're going to do
hex we're doing hex
because the computer is really working
on binary
which is the truth that's actually
what's implemented in the hardware so i
can
i can look at it with my electron
microscope and i can see bits flying
around
but we give them positional meaning
by putting them into strings of bits
right so that was like if i have a 32
bit
number then it's going to be a lot of
bits that i'm going to have to write out
here
so here's my this is my 16 and
here's 32.
okay this is not fun to write so we want
a more compact representation of that
and that's basically
hex we just say by convention if we just
break this into groups of four
then one of these groups of four and i
just got a straight line there but one
of these groups of four
corresponds to a single hex digit
okay yes so i can represent this 1 1 1
1 as f because that's actually what it
is on the
hex table if i count it out one two
three if i end up at f that's all the
bits
lit up so d would be like i did before
this would be that
and then i'm basically just going
backwards in binary
okay so this is actually what the
computer is doing
this is just for us so really long aside
later
when i when i come back to this coding
window
for the 18 viewers that are still
hanging out
hey we've got we've wow this actually
love the nitty gritty as much as i do
nitty gritty was
more it brings viewers then you know
this
kind of get all right that's another
tangent you know what that's literally
when i go on one
that's literally when what literally no
one cares about this i
have more like i guess people care about
this so i'm going to continue to rant
like
this you know what you sold me i'm
getting a flask
and let's just do it that yeah we're
doing it yeah okay
so we're going to rename the the c
coding session
well so there is there is this amazing
um
stream that's that some sort of like
twitter
associates of mine have been doing all
on like drunk science and i'm not saying
people actually need to get drunk i
can't science when i've been drinking
but
like a whole lot but i think there's
something to be said about two people
from like
very different backgrounds learning
about a topic
with you know some tasty beverages it's
fascinating because as you've been
explaining things to me
as hard as i have been working to like
you know activate the
the the the tiny baby coding brain that
i have i keep jumping back to like
you know my linguistics background or
something and that's what's been
been tripping me up in some ways is kind
of this like
for for the super nerds in chat like i
love you there's probably maybe one of
you
like like the origins
of representation of meaning right so
sores
the signified and the sign like we have
a we have a concept that
we need to represent with some kind of
symbol
and we're taking that one step further
because we're like we need a symbol
and we are limited to yes and no
or zero and one yep and so how can we
chain these things together
to represent complex meaning and that's
that's a
fascinating linguistic problem but
that's exactly what we're going to be
doing in c
actually see maybe like maybe when when
you teach
when when linguists want to learn to
program then see
i mean but i think they have to come at
it from the background you had i think i
think that makes more sense if you've
been in a language like python
and you sort of have a better sense of
like what's going on and how to get
things done and then you want to go
now how does that work i mean that's
that's true so when when
i mean i am not by any means not
scientist i'm not even a programmer
really i'm i'm sort of like a like a
what would you call it a like a
aficionado i guess it's somebody who
loves it i would call you a programmer
because you've been running
pro you've been writing programs and
you've been running them
yes you i mean that's very sweet but
like when people come to me and they
want to learn how to code
often especially if they want just kind
of a basic understanding of something to
do to
to stretch their mind and to kind of get
their feet wet i do point them in the
direction of python because yes while it
is hand-holding
while there are some hand-wavy stuff
going on
it's intuitive and it's readable and
pseudo code yes and that's i mean that's
the thing right it's like
you i mean even just with a couple of
weeks of learning python you can look
and it makes
sense well unless you see a
comprehension yeah until you get to like
the land that i'm in right now where i
download
what i don't understand and yes strophia
am i completely
beauty of it though like it's learnable
and so
i i do agree well you know like it's
accessible
let's let's put it that way okay waxing
philosophic aside because we're going to
need more hours if we're going to get
into that
there are many hours there are many
hours no no they're countable
we're what are we where are we base 12
or
we can do the math at base 12 if you
want but all right before we do that
let's um let me just wrap this up
because i know you had a little bit of a
time constraint
um so let me just wrap
this up by saying i i'm how does what we
did in our really long tangent of
getting to roman numerals and realizing
why positional numbers are great
which is totally a different thing um
this uh oh uh that
is okay um that that's that limiting
factor is really up to you
so you're fine uh i just i i felt bad i
was trying to be i'm like we're way over
all right
this is this is the beauty of learning
okay well
what we were doing before before we got
into the mess of negative numbers
was we were realizing that we had with a
basic eight bit
uh if we have eight bits worth of
position so this is this is all we're
going to have
then the maximum number we could fill
out looks like 1
1 1 1 1 1 1 right
and the shorthand way of figuring out
what that is in decimal
is just add 1 to it here which is going
to cause all of these
to overflow and they all do their thing
and then you'll end up with like
one zero zero zero zero zero zero
zero zero okay so
this corresponds to two to the eighth
okay because this would be the two to
the seventh digit you know putting a one
there
is two the seventh and so yeah this is
two to the eighth so if i do that minus
one i end up with my maximum number is
255.
now i can shift that range over because
i have this problem with negative
numbers
and that gets into that a little bit
messy and for some convention reasons
that i'm not
fully explaining and i apologize for
some of the hand wave we're realizing
that
a really good way to do this is called
the two's complement and
yep we're good we can go into a lot more
detail
on that for you later but basically the
idea is that
it's a complement so for every number
i can take this maximum thing this two
to the 8th
and i can subtract whatever number i
want so let's
just call it x for the moment and that's
going to give me
the x complement
and complement not in the complementary
sense
like oh yes you know hey x how are you
very much approved not not this kind of
compliment so
we're we're talking about the complement
is in this is the matching part of
x so the matching part is the other
thing
that's neat except here i had to choose
how many bits i had right
so this eight bits corresponds to the
basic care type
and when i adopt the standard convention
the standard character is signed which
means that i really only have 127 of
these
and then i have a negative 128 of these
if i'm
i forget which side we added on but i
think that's it
and that's that's my signed character if
i make
care unsigned
you're limiting yourself to just 120
actually i'm removing the limit because
here i was going from
in a normal character that was signed i
was going from 127
down to -128 and because of this little
messy problem with like positive
negative zero
i had to stick that extra thing
somewhere and so i stuck it over here
okay so what happens if i relax that
constraint and i say you can't have any
of these
so then you get two hundred and fifty
five exactly there's fifty seven
if i put those over here i get another
bit that i can use it's no longer a sign
bit this used to be the sign bit
so why would you ever use a signed
character then
why would i ever want a negative number
i mean
no but i just tried i just tried to put
character and negative number
and it's good last miles there's your
your dude last model show
hey hi it's about time
i'm sorry to interrupt your question
what would you no no so you were saying
like you know you can choose signed on
and so yes i just tried to put character
a negative
and it didn't work it like barfed out a
bunch of problems at me
and so why it looks like i've got some
python bugger either
but like why would you ever need it oh
yeah
so that's a nice one you're
you're you're responsive why would you
ever want a negative number
well the first problem that we have go
negative characters don't
okay put care actually doesn't accept
negative
numbers i mean that makes sense right it
makes
that that blew up on stream is actually
due to how i implemented this tool
um that that actually what it tried to
do was it you went past the ascii range
and by default python will throw that
away
because it doesn't know which encoding
you're choosing so it just defaults to
crashing
which is kind of a sane thing to do
turns out but
um without answering that question why
would i want a negative character i
don't
okay it actually has to do more with the
fact that i really don't want negative
characters at all what do i really want
in terms of negative things
terms numbers yeah when am i going to
want something to be negative
when we're dealing with numbers not
characters like it's a little bit
abstract to talk about character being
positive or negative
it's just adopting all the conventions
that regular numbers do
now i told you before how many bits was
in an integer
were using the c99 standard
so in the c99 standard how many bits
were in an integer
eight no see that i'm guessing that was
k i don't know
that's okay we didn't we didn't talk too
much about it um this was actually the
main
meat of what we were gonna get to
earlier before 16 i'm just going to keep
going up by yeah so
it used to be 16 um back in older
standards so we're
it's not anymore i mean i know i know at
least in python i usually deal
but i'm not sure which one well double
this number to double the 16 and you're
going to get the right answer
32. by the time we got to the c99
standard it was already standardized as
32.
it used to be defined as a convenient
size for the architecture that you're on
which was very bad for writing portable
code
because everybody was yeah i mean this
this had to do in an era when there were
like 8-bit bytes and there were 12-bit
bytes and there were
you know other weird things that you
could do in hardware you know and so
that that era is kind of gone
so we're talking more about like modern
c where int becomes a 32-bit thing
pretty much all the time but if we
accept 32 bits
then what's the maximum number that i
can read that i can have
whatever 32 ones so exactly
i'm not going to yeah i'm not sorry i'm
not going to do that okay so
i i've got four groups of eight right i
could think of this as eight
eight right
right i mean if i add these together i
get 32.
chat check my math
this is probably going to be i feel like
this
go off like when i asked about negative
characters
but or signed characters how the
heck do you do floats oh we're gonna get
to that in a moment
but okay all right let's finish this my
brain is like my brain's hurting now no
no i know and
it'll really hurt if i answer your
question about floats
what because you could do i could see
you doing decimals
as if if if somehow in in magic
binary land binary became not binary and
i was able to add a negative
then i could see like or or somehow we
were able to kind of like go negative
yeah we're when we're working with
numbers we do want things to be able to
go negative
right yeah this has a lot more meaning
than talk like a plus or minus
integer has a lot more meaning than a
plus or minus character
this is a little bit silly but yeah
that's why i got stuck so
this sort of fell out of the standard
for reasons we're gonna get to later but
um you wanted to know c right
i'm here for the fun okay so this was
um this integer is kind of where it's
more meaningful and they're we're still
adopting the same convention which is
we need to keep one bit available for
sign and
again we're going to use this two
complement thing when we're when we're
going negative so
so basically our algorithm is going to
be like less than zero
than two's complement
there yep okay yep okay and greater than
or equal
to zero just normal
so that's our that's our way of dealing
with sign exactly the same as with care
now i showed you with care because
care is only eight so i didn't have to
write that much if i was writing out 32
bits for every single line we'd be in a
lot of trouble
so um that is basically
why we also like to use we stop using
binary at this point
and we just split these each one of
these eights corresponds to two hex
digits
so ff f being one one one one
for my earlier bit pattern this course
these boxes are four
yep yeah so basically if i put two of
these hex digits together
i get eight bits so there you go
not trick question how many uh
how many hex digits do i need to
represent a 32-bit number
i mean the biggest one i'll just write
out for you so eight
right because if yeah right each
hex digit is four yep and so 32 divided
by 48.
you got it so this is really convenient
that we get to hex by the time we're
writing numbers that are this big
and that's exactly what showed up in the
chat by the way
so earlier they were like okay what is
the biggest number that you can
represent
it's this it's all it's eight f's f
f f f f f
f f
so this would be the biggest 32-bit
number you could have
as long as it's not we're not treating
it as signed because otherwise this
this last digit here this one
corresponds to a negative number so this
would
not be the biggest number you could have
if i'm using a signed integer i'm sorry
light bulb moment
okay no no no this is something probably
i'm so sorry you probably
an hour ago but just sunk in
is wow that's why you have to specify
the difference between
unsigned and signed is that unsigned
gives you a bigger range but if you need
negative numbers it's going to cut off
like you're positive that's
right exactly it oh my gosh okay sorry
the light bulb
like eureka it happened i'm sorry you
probably
forever go but my brain just no caught
up that's
totally fine i'm actually i was actually
very long aside to answer your question
that feels good to actually get that
like okay
i absolutely needed to get to and that's
actually now it's a lot more meaningful
when i'm talking about integers
having a sign as opposed to characters
having a sign because characters are
just
representing symbols in their base
capacity which is what they're the word
character
it refers to a symbol like an a a b a c
that kind of thing
but and and that all fit really nicely
in
eight bits because eight bits what was
the maximum
that i could have oh lord eight bits
um oh shoot
is that 255 yeah yeah yeah yeah so it's
actually two to the eighth minus one
because you know otherwise you overflow
so that's 255.
so that means i get 255 symbols that i
can assign
uh 255 different bit patterns right i
can have zero zero zero
zero zero zero zero zero i can have zero
zero
zero zero zero zero zero one
and so on there's 255 of these
okay why is this convenient well that's
enough space to have
all of the uppercase letters well there
i go
writing in hex all of the uppercase
letters which corresponds to 26
right all of the lowercase letters
which corresponds to another 26. so i
need at least
two of these right i need 52. to be able
to represent
all of the uppercase and all the
lowercase old computers didn't used to
do this by the way
they didn't have lowercase so everything
was kind of uppercase back then
so you could save yourself a bunch of
bits that way
but we like lowercase letters right
i mean i don't know about you yeah what
other symbols do we have that we need to
represent well we have zero to nine they
need symbols
and then we have stuff like a plus a
minus an asterisk a
carrot a square bracket another square
bracket
a brace another we have all this other
symbology
so when you pack all that together they
said okay we need
at least five bits
at a minimum okay because five bits
corresponds to what's the biggest number
lord um somewhere between
128 and 256 it's a little less than that
two to the fifth is what
32 oh is that okay no so it's seven is
oh
exponents god okay yeah i'm with you i'm
sorry no no it's
got to get you back to this planet yeah
totally fine so we have two to the fifth
minus one that's going to be
32 minus 1 is 31. so that means that
i've got
the biggest number i have is 31 but that
gives me 32 separate symbols because i
also get zero
that's enough to encode one of these so
if i have 26 letters in my alphabet
i've got 26 plus i've got you know
another
seven available for all of the other
symbols
well that's possible but it skips over a
lot of stuff
right because we wanted to have lower
case letters too
so if we want to have lower case letters
what do we need to do
more bits yeah we need another bit i
mean if we want to include that we need
at least six bits
now if we want to start adding like
control characters like okay
take the printer that you're running and
have it scroll
up a line when i'm done printing this
thing so we have all these control
characters as well well what do we do
with those
well all right we'll call it seven bits
okay and this is basically
ascii this is the american standard code
for information interchange
and that's where they stopped they said
all right seven bits is cool
i've always wondered what asking meant
like i'm frantically trying to find my
oh my god because america america
okay well that's why ascii but that was
fine as long as i my letters looked like
things like
so in seven bits what's my maximum
number
seven bits is that one is 127. you got
it so my biggest number is 127.
and that includes my 26 characters of
uppercase my 26 characters of lowercase
a whole pile of symbols a whole bunch of
control characters all that other stuff
let's just we used up this entire
thing because we want to be able to have
the underscore and we want to be able to
have the hyphen as well which looks
similar
unless they're on the same line so and
then we want to be able to have things
like braces and then close braces and
then parenthesis and then a closed
parenthesis and then a square bracket
and then a closed square back
okay so all of this stuff
they ended up choosing like they said
all right this fits into seven bit it's
totally
occupied what were the americans
forgetting when they did this
accents there's other parts of the world
aren't there
so yeah like other alphabets or just
accents
and so the original answer was well
we're not gonna answer that and so
everybody and their brother took the
last bit they said all right well we're
going to call this eight bits
because this is a powerful american and
i'm sorry that's so
american to just be like yeah no this
part
we're gonna reserve we're gonna call
this ascii down here
okay well what does that leave for this
like if you use this
sign bit which we already went to town
and back on
why it's not really a signed bit but
it's negatives it means
negative letters this expands our range
to eight bits if we're using eight bits
then how many what's the maximum number
we can have
255 yes it's two to the eighth minus one
which is 255. okay
so that gives us 255 symbols including
that zero null terminator thing which is
anyway it gives us 256 totals no bit
yes i remember the null bit yep and so
this part was specified and then
everybody fought over this other part
and we got a whole pile of encoding
messes like this was like
one thing after another there was like
you know you could have like
the ibm code pages so you could have
code page 750 you know
whatever i forget all the old code pages
like code oh
we want that back we could have like
code page 430 or we could have
like shift gis you know we we could have
uh
you know one one of the standards for
representing ideograms you know we could
have
things like this we could have we could
have big five in coding we could have
also lost me but i assume this means
something we could have
ebcdic yeah basically there's well this
this actually was fighting sort of at
the same time that this was funny
but we could have like iso standards we
could have
iso 88-59 yeah see nathaniel's right
there with you like
one yep 88-59 yep seven
you know like you know where do you put
the hebrew characters where do you put
the
arabic characters what do you do when
you get to chinese
how many characters are there in the
chinese language
well okay nope linguist hat off
that's a rhetorical question they're
nodding they're still discovering
characters
okay but literacy basic literacy is
defined in china as about
2 000 characters yep
how many bits are you going to need to
store 2 000 characters
that's the fascinating thing about
chinese and similar like
just that you instead of a
a particular symbol being associated
with a sound you've associated with
meaning
and so instead of having the breaths of
sounds that the human
sort of mouth anatomy can make which is
actually
quite that's quite expensive you're
talking about right
you have you know you have breadth of
you have the breadth of human meaning
instead which is yeah so i i was i was
drawing a parallel between
you have languages like english that
encode sound
with with the symbol so you know we we
see a k
for example and unless there's an n
before it we know it
it's a hard kind of like c sound i won't
go too linguistically into like
the anatomy of your of your mouth but
then you have languages like you know
ancient egyptian hieroglyphics
or in this particular case like you're
talking yes korean
um korean i believe is actually more
like which encodes
sound with a symbol you're talking about
modern korean
modern korean yes and chinese kanji
classical korean does not it uses the
kanji
really yep that's interesting same story
with vietnamese
by the way vietnamese now uses an
alphabet but does
not in other cases like in ancient texts
for example
so like really interesting so what do
you do with the cardinality because if
2000's basic literacy and more advanced
schooling is like eight to ten thousand
characters
all of these are about the same
cardinality
like when you're talking about all of
that stuff that i just mentioned so
you're talking about like easily 100 000
characters we need to add on so how do
we encode this
well that's a lot of bits i mean the
answer so far
like you know me little little student
here learning has always been ad
bits i mean that's been the answer so
far right is
more bits we need we need letters in the
first place more bits
so yes that is the answer it would be
more
bits and actually the funny thing is
that eventually we decided to take
all of the different codes that were
being created in all of these different
places like
you know there's the japanese
information standard there's the
chinese was creating the big standard
you know there's the there's
there's all sorts of like different
there's like the hk sar extension of
that
you know there's there's all sorts of
stuff that's going on
to get all of these languages eventually
we said we don't need
all of these different encodings
okay why not the one in coding
what to rule them all and in the
darkness
okay we need the unit encoding
we need the unicode
[Laughter]
this this we eventually do solve this
problem and by the way in c
it is going to be a nightmare but we
will
we will get to that a little bit later
because this stuff can get really crazy
like there's
a whole lot of stuff um i
that encoding is a topic that is it's
definitely advanced in
in in this stuff and well that's the
funny thing is that something that i run
into a lot because
not not obviously as a baby
but working in python one of the
difficulties has been
as i kind of work for clients that are
less
how shall we say technically advanced
and they're like here
take my data repository in the scariest
of scare quotes
and it's really just a hodgepodge of
like word documents pdfs
figure it out encoding becomes a problem
because as you start to try to scrape
data from all of these different formats
i get a lot of encoding errors and so
i've had to kind of learn some of this
like
not very well now
frantically panic googling right before
i have to like
submit some code but this is
it's important and even though i think
for a lot of people they might think
this
is too nitty gritty this is too kind of
under the hood
if you work if you try even
as somebody who doesn't want to
understand the under the hood
if you try to kind of write code for
clients that don't already have
a wonderful perfect database system or
you know storage system whatever for
their data and it's perfectly you know
organized
and whatever then you're going to run
into this stuff
very very fast so i feel like this is
actually what sort of started me
on this path of wanting to learn a lot
more is running into
problems like this and trying to kind of
dig deeper and be like why
are they what even is utf-30
what what does utf even mean yeah what
what are all these different
random errors that i'm getting and what
isn't cody what is happening
and i think if you teach yourself code
that stuff pops up and you're like
huh what is this stuff yes and so it
makes sense you know so
it's this is this is very fascinating
that's actually why
python through earlier when you said -10
when you did a put care on -10
the back end of this web server is
running in python and
it's actually it's it's up and down
that's right it's not running in c
it's running it's not running in c it
wasn't i wanted to actually ship it
reasonably soon so it's right here in
maine but um and what it's doing is it's
realizing when you did this -10 that the
number was outside of the normal
ascii range and as soon as you leave the
normal ascii range which is the bottom
seven bits so when i go to the eighth
bit
which is going to correspond to what
number so what's the biggest number i
could get with the seven with seven bits
seven bits okay so
127 that's correct so what happens as
soon as i show the character 128.
um bit wise what did i just do
so you've you you've i mean are you just
gonna get like a
like an error of some kind because
basically
i mean you know c has no problem doing
it
python does on the other hand python
very much has an opinion
and python goes hey you gotta choose an
encoding
like i'm going to default to ut if you
don't say anything i'm going to default
to utf-8
and that's not a valid utf-8 sequence
so oh python and that's actually a
pretty reasonable default for a modern
language but
um c on the other hand has has no
opinion about it it'll just display
those bits and it's up to the terminal
to sort of say well i happen to be in
this encoding so i'm going to turn it
into this that's when you start to see
like all sorts of crazy stuff
okay so yeah we're totally going to get
into a language war here
oh no oh no no language
yeah you need one of those like chat
chat
um oh no aliases just to be like war and
it's like nowhere
unless it's javascript which no they're
already talking about sgml so this is
about to get really dirty
i have no idea what that is now
nathaniel i don't want to see that kind
of language in here no no
sgml so
that's that's a that's a pretty crazy
standard that
that nathaniel's referencing okay but
anyway um
that's actually what happened so as soon
as i did this minus thing oh my god he's
just
oh no what what is that please do yes
no i won't three i'm googling
no no no okay so document style
semantics and specifications is this
just latex but
sad don't don't look at it don't look at
it
okay style sheets when i went back to
your program
and i changed the number from 128 to 127
i was staying within eight bits
of data or sorry seven bits of data so
c and python both agreed they had no
problem they just displayed it now the
character is actually
a backspace i believe i think it's
delete um
i'd have to then have to learn
um this okay sorry yep yep so so
this is where i'm sorry like this is
i'm sure for especially everyone in chat
who
miles ahead of where i am right now it
makes a lot of sense
that's a delete where of course
there needs to be some kind of
representation for the very
keys that i have on my keyboard because
so far i've taken this sort of link
linguist
approach of we need representations of
meaning
but to have a delete seems like it
should be more of a function than it
should be
a character if that makes sense like
it's it's an
operation how do you type it on a
keyboard
i mean i mean wouldn't you just kind of
drop the last thing you did like
yeah but maybe then the keyboard would
have to know the state of the computer
to know what the last thing was well
that'd be a very expensive keyboard yeah
i mean
i guess again it's super ignorant so
like people can laugh but like i guess i
thought like
when you hit a backspace or something
that that was a trigger
it's a trigger but
it depends on the encoding so it's like
an old style it was it a backspace is
right here it's you know it generates an
eight so i mean that's that's that's
really cool for me because i my
my hardware my software knowledge there
there are many miles between them and so
when i've built the electronics that
i've built it's been very simplistic
but it makes sense that you would have
representations like if if i were to
create the hardware that is this
keyboard that i have in front of me
it would make sense that i would then
want
on the sort of internal level for the
various keys so that does make sense but
i know i know for so many people right
now it's duh
but for for folks self-taught that
actually is
fascinating that's really interesting
that it's not just over
simplifying because it the keyboard
actually generates a scan code it
doesn't
it doesn't do exactly what we're saying
it doesn't turn it
necessarily into ascii but
but i don't want to go too deep into
that but i mean the moral of the story
is that like even older hardware like
the terminals they're talk like the
vt100 that got brought up in chat
or you know the fact that originally
this stuff was hooked up to a printer or
punch cards or whatever we needed a way
to represent everything that was kind of
going on
and yeah i agree with you i think that
is fascinating i mean
i had to learn it too at one point i
wouldn't call it duh
i'd call it like probably something you
never thought about especially in python
it's it's just i guess this is again
that kind of
writing notes sorry um this is this is
the interesting
sort of connection that i want to make
at some point is that i've built
i would say very primitive electronics
myself
on a hardware perspective so like um
the most complicated thing i've built is
like a whack-a-mole machine
yep and it was really fun i got to learn
a lot about
circuits and i
learned a lot very fast i said it for 38
hours it was a really bad time but it
was actually
i think that there's almost like a
not a not a sort of crotchety boomer if
you will
sorry friends uh like taking it for
granted kind of mentality but there's
just
it's so easy now to
learn python to say things like to just
hit a backspace
to print things very simply very easily
especially in jupiter notes and so
especially as you have started to teach
me c and i've realized that
even just kind of printing things out is
a lot harder than i expected
but also like how do we represent these
things
from that our level of on off
to the full complexity of what we need
to
encode that's really cool
and it's not intuitive it's not
something that i've really thought about
it's so it's really really cool
no it really yes um
i i completely agree with that i
don't think i have anything to say to
that i think that was more about
you're thinking you're thinking out loud
but yeah sorry sorry i don't know that's
all right
i i i heard in there was wrong
computers tonight i really do i feel
like i'm going to dream about this i
just have that feeling
now this is totally really cool okay
well let's let's go
just one i just want to close this up
with like one little bit because we've
done very little c
code so you shall not pass
sorry i'm sassing strophium because yes
balrog
so i was awesome oh wow yeah
yeah i aim to be the computer science
gandalf
okay awesome well let's grow i don't
have that like
i don't have that follicular power i
just don't
so i'm sorry okay let us continue
okay um so here we are we were putting
cares we learned a little bit more about
how all that's organized but let's get
back to our basic type so we had an int
right so if i have like an integer a we
had a care
like i had a character b and you know we
also had
float which we didn't really talk too
much about like i'm just jumping ahead
with that's fine that sounds scary in
terms of going
depth that we did i will leave that for
another q
or something yeah we're gonna get to
that later
um so these two basic types i've been
kind of hammering at how they're stored
in memory
but c actually does give you an operator
to figure that out
as well and it's called the sizeof
operator
and it does pretty much what it says
so if i how do i print out a number just
going back real quick
okay so a number we would go
we can use the routine don't do it by
hand
and we would put some stuff with
percentages i think except we have to
mind our quotes because we're in c
not python sorry percent d
and then i think there's like a
backslash n maybe except that's a front
slash
okay backslash oh oh okay
there it is windows all right and that's
a new line
um then whatever the number is yeah
three that sounds good
yeah i did it okay separately to
semicolon because we're inside
[Laughter]
okay so let's get rid of the the other
put care
i'm just going to comment that out go
ahead and run that program
okie okey-dokey yeah
all right let me yes clear the output
all right so we execute that
we're able to put a number on console
now how big do you think that
int is that that int a
hang on a second give me a second okay i
got this it is two bits
okay our theory is it's two bits you're
calling that a two-bit integer huh
i don't know okay that was my
punch my
so let's why don't we have the computer
tell us let's not guess
okay that's the size of operators so why
don't we say what is the size of a
oh god there's no parenthesis all right
yep no because it's not a function it's
an operator
okay but all right we're fine yes
i'm good okay yeah go ahead
so what what
what oh wait wait wait i got you hold on
so
so so so hang on i have a theory here
we oh i'm going to use python language
i'm sorry i don't know the right
language
don't form a theory yet don't form your
theory yet hold that hold that theory
from forming
i know hold that theory from forming
what happens if we look at this
eight eight it's eight what
it's eight bits what it's eight bits
you're correct one bite
one bite which is one bite yes okay
all right so what's that for
four four fights sixteen bites
four bites is not sixteen it's
wait if one if one bite is one eight
thirty two
thirty two i'm sorry exactly all right
all right so
caffeine has long worn off no that's
totally fine we're definitely getting it
so that's why we're gonna wrap up with
this operator don't worry this is when
my brain starts to play like
no no we're good in fact we should have
got there earlier but we spent all those
brain cells on encoding and bits and
twos complements and everything else
so okay we have a way of telling what
the size is
the only catch is that it shows up in
bytes
sound good okay yes okay so if i do the
size of it pretty much
it works with types so i can say give me
the size of a care
now i'm a little confused i'm sorry so
this is where
again this this this patchy knowledge of
mine is probably going to
become an obstacle where i thought that
okay oh lord this is probably very
ignorant but i thought that
the difference between bites and bits
was not kind of like an
eight to one whatever it is i thought it
was one is a
one is a rate for like internet speeds
right
and one is more of like ah that's how
it's static memory
no no we're talking about what it is at
its core
okay all right and by the way and i'm
just clarifying so that like
i'm that i'm sorry you're not you're not
wrong that comes from a very different
domain
um okay and that that kind of comes from
the fact that bits themselves
correspond to what is a bit it's a
binary digit
all right right you have to take the
pads i got you there like that that
makes sense
binary happy place and then we went to
bytes
yes it comes from the word binary digits
just a contraction
okay so digit being
just decimal you know if we if we don't
specify then this is usually base 10.
so this is kind of like the numbers
we're used to
okay yep what what is a byte well it's
just a chunk of bits
different standards historically got
into a whole bunch of fights but we're
doing c99
so that means you just call it like a
like a like octo
uh and actually that's exactly how it's
referred to in the standard
standards referred to as octets why do
they use octets because it's unambiguous
thank you back in the day when there
were 12 bit bytes and 8 bit bytes and
4 bit bytes and every different
manufacturer chose a different number
for what byte means
well octet was a story right and so the
standards documents whenever you look at
them they're going to refer to octets
because
this is always eight bits there's
there's no
there was never a difference from this
that makes more sense than a byte to be
honest i'm sorry
like that's we have we have st we have
we have scientific nation
wonderful standard i didn't engage with
the world
i know you are the representation of all
of the knowledge
you're gonna need to know bytes you can
fix
it in the modern world you can treat a
byte as an octet you can
treat these pretty much interchangeably
but you know if we do look at some
libraries when we look at some c code
later
we're going to see that there's 12 bit
bytes and all this other crap so
in the c99 standard it's unambiguous a
byte is eight bits
so we don't have to worry about that
it's always eight but
bits as far as we're concerned okay so
if we know that
32 bits shows up as how many bytes
32 bits shows up as how many bytes four
correct
because eight bits in a byte yes all
right so
size of operator returns bytes you can
guess what kind of fun there was in the
standards at that point
so reasons
no we're not getting into endianness
people have been saying that already and
so all i know is
we talked about it briefly in the
lecture earlier but basically it's just
kind of you're writing left to right or
right to left
when you're going across bytes but bytes
as we learned already a little bit messy
um but what i can tell you is that
networking that we brought up briefly
when you were talking about bits and
bytes
computers kind of grew up using bytes as
storage
you know so like we would say like how
many bytes does your hard drive have
i mean right it's been a long time since
we said that but i mean you know
like obviously byte was not a very
convenient unit so we started using
kilobytes and then we started using
megabytes and then we started using
gigabytes and then terabytes and we can
eventually go into the future in star
trek and we could start calling them
quads
cause f it so
star trek oh yeah how many but i mean
that's
like we should have just stayed with
i don't know i mean well i'm not that
i'm not going to get into that's more of
a history talk but
yep you're fine what i am going to say
is that this
this bite world grew up around computers
now
networks on the other hand they were
concerned with like
morse code kind of stuff you know like
how many like
dits and daws did you pass which would
which would correspond to binary
so how many binary digits passed on this
wire and so they started using bits i
don't
really know what the original reason was
i i think it was to make themselves feel
better about how slow their
their streams were because when you get
people to start talking about bits
suddenly things are seem a lot faster
right because the numbers inflate by a
factor of eight
fair enough okay all right so they
adopted the convention and networking of
using bits
i mean they're literally using wires
connecting networks
i mean so it's not too crazy that they
would be
operating on bits especially when you
talk about serial and some other stuff
that we're not going to get into right
now but
um they adopted the convention of using
bits so yes
to your comment like when you're when
people usually refer to like mega bits
they're almost always referring to a
network speech speed
right yeah okay so i always thought it
was like this is computer science
people's way of distinguishing
meters versus meters per second they
just use different words
nope that's just they they both refer to
as
like if you're talking about mega bits
it's actually megabits
per second so like you know
mbps was kind of referring to like bits
per second because back in the day we
had modems that were measured in bits
per second
like oh i've been there yeah and then
eventually we had kilobits per second
and then eventually we had megabits per
second and
if you're in a really good part of the
country you might get gigabits per
second
and if you're over at netflix's campus
you actually get a tear a bit
which is pretty cool oh what which is
just
absurd it's so absurdly fast that
generally you're just waiting for the
other server i mean
it's it's kind of crazy um
something bad happened which is why i'm
not answering your question about si
units and i don't want to get into
no worries you're fine you're fine you
can give me yeah you kind of like just
old please and as long as you come back
to it at some point in the future i'll
be
yeah that has to do more with storage
manufacturers and then
non-standards and lying and feeling good
but
anyway um we're dealing in powers too
and we're dealing in bits so we're not
worried about that
that stuff okay so
now we know how to get the size of a
particular variable right
yes via size of the operator
not function that's correct and it's
sort of like in python 2 when you had
print
printing no python 2 makes me sad nope
nope
stuff right i like i like the
parentheses because it's like this
little package
and it's like math well because they
eventually said like why is this not a
function
this should not be an operator but
that's the thing i'm sorry but like
look at look at math right okay i'm
gonna i'm gonna sorry it's
math sas for five x times y plus
z this means very different than
sure and so it makes a lot of sense that
if i say
you know there is a it does doesn't
matter if it's an operator or
function an operator and i want
you know stuff i'm going to put it in
parentheses to give it its scope it's
scope of operation that makes so much
sense
or the size of thing bothers me a tiny
little bit but i will get over it
well unfortunately there's very few um
operators i mean like size of and return
i mean
there's not many more i mean that's
that's fine i literally just
i i the parentheses makes it similar to
math it makes it easier to parse like my
my computer science programming order of
operations
return is not a function so we're not
allowed to write this
but what okay well okay
so i like it that way yeah i know
let's make our own programming language
now oh hold on we're gonna learn c first
don't open that can of worms quite yet
okay
so that's i think probably a pretty good
place for us to stop i don't i don't
think we should go too far down
um there's one little trick that i want
to show you which is how did we do
strings last time
strings um so i remember you telling me
that
put or sorry print f is
something that is from that include s t
d i o dot h and so normally we wouldn't
be able to print a string
but that kind of gives us that
functionality and so
yeah i remember being able to print
strings using print
f but you mentioned that sort of in like
the base c if we don't import
using python language sorry import this
particular
yep functionality we we would only be
able to kind of
put care yeah i mean
that's it that's all you get
okay so if we wanted to actually build
that that's fine but
back when i was building a string we we
did a shorthand notation
um and that got a little bit into memory
representation which
i think we should probably just save
this for next time
um like so when we wanted to do
something like this
we it didn't work though i thought right
oh yeah
it kind of works i can make this legal
if i play with a little bit but
um this let's save this for uh
let's save that for next time i think i
think we've we've done enough torture
with math and
representation so
all right well i know uh chat has been
very active
this has been wonderful i've learned so
much like
this is i know we kind of went off the
lesson plan and i
i appreciate that doesn't bother me
that's that's that's the wonderful thing
about not
learning this via some kind of college
class is that i can
we can go down those rabbit holes and
that gives me that really deep
background knowledge that i find is
necessary when
i want to build from a solid foundations
yeah
thank you i appreciate it i appreciate
the we have to avoid some of the traps
that uh chat keeps trying to get us into
like oh hey when are you gonna do this
it's like
okay hold on let's let's build one thing
at a time
chad i know you get excited with some of
these new concepts but i i i don't want
to go
too much too fast otherwise we're just
going to create a mess of jess's mental
model
so i i'm pretty resilient don't worry
well then you're just gonna look at it
wow it seems impossible forget it
i'm very very difficult to just wait i i
oh
yeah don't worry i'd rather dissuade you
when we get to some memory stuff rather
than
give you too many operations at once
like i don't know i don't remember all
that
okay cool well
i think uh yeah i think that's a pretty
good place to stop
uh sorry chat if we uh
didn't uh get too much into the topics
we did barely cover what we said with
the review of types and size obstruct
that's fine i think
it's good to kind of i don't know it's
nice to finally
have the not just be like no
we're sticking to the lesson plan like
you're not teaching me
to to pass some tests like we're
learning for the sake of learning
we don't have that's the beauty right
like this is that's that's the beauty is
like we can learn whatever it is
learn i mean the only true test i'm
gonna see someday is
like whether or not you could write a c
program like
someday if we go through all these like
hours and you can't write any c
i'm going to feel that i failed you i've
got i've got that screen
from my for loop my first see i have
that screenshot
so you know what we'll come back to it
we'll come back to it in like probably
months and we'll be like yes
look at this progress yeah see like look
at look at strophium and chad i'm so
stoked to teach you gamedev now it's
like okay
one step at a time before it's like
going on about like yeah c is much
easier to explain than c plus plus
that's part of the reason we're starting
there but it also requires a bit more
understanding of
the architecture of the entire system
which is why we're
getting a bit more into bits and bytes
and fundamentals um
not lord byron i thank you i
uh i don't want to fend you all off too
much i mean you want i want you to have
fun too but
you know it's some of it i think i'm
worried that
i'm worried for jess's brain oh my brain
is my brain is a hearty uh
yes but i don't think i've never told
you this like i went into graduate
astrophysics having not taken math
70. i i
broke up a little bit at the bot at the
end there i missed that oh no
i i just said that when i went into my
graduates
i hadn't taken math since high school it
would have been seven years
um so i got i got you my brain can
handle
and i will oh i i'm not worried about
whether your brain can handle i'm more
worried about like if we're building
enough
cognitive scaffolding for you to you
know
like i want you to acquire this
knowledge you know i don't want it to
just sort of
bounce off
nathaniel so to answer your question i
did no um i went to a really weird high
school
that taught all the way through
multi-variable calculus but then i spent
uh four years college and my i left
early my senior year to study
um uh outside of
outside of high school like a i forget
what they call it like a dual dual
enrollment
um and so i hadn't had math in about six
to seven years by the time i entered
uh graduates so uh that's pretty cool
yeah
so i had it like seven years previous
but
it had it had been a while um
i uh yeah no that that's great actually
i mean i think you're doing well with it
just
um i do take more of the stance of gob
father that
c plus plus does have a lot of stuff in
it like i think it's a lot easier to
learn
c first and then learn c plus if you
want to go down that path as opposed to
learning c
plus and then trying to make sense of c
later
i think you'll end up you gotta you
gotta kind of get like a better
model of the computer i think to really
advance at sea
um but i can't wait for that
no it's happening i mean this is this is
already quite a bit um and
thank you godfather for the follow i
appreciate that
learn all the things nice i just saw
your comment all you need is gdb and
some patience that's
not lord byron that is probably the
understatement of the century in terms
of patience
but we'll get to gdp later that's uh no
tests what is this
can't wait for that one yeah i
completely agree loaf book um
i'm glad you all had fun um i'm glad
that i wasn't
having a drink i think those rabbit
holes would have been magnified we would
have shifted bits like crazy
yeah i don't by the way strophium i've
seen that style of teaching i really
don't like it
where you talk about c plus plus without
like you just sort of jump straight into
the
object-oriented aspects of it but i feel
like that doesn't really build a very
good model like that teaches you how to
work in c
plus as quick as possible but we're not
in a race we're not we're not
up against like she's not about to go
into a corporate job for c
plus like tomorrow so i think if we were
optimizing like
time spent versus like payoff in
corporate sector then
this is like we're taking a longer curve
to kind of
build up to that knowledge but i feel
like you're gonna have a much better
understanding of it jess by the time we
get there
i i honestly can't wait and i like that
approach so i mean i can do some oh
fun but like i constantly am aware of
the fact that i'm missing that
foundation
and i feel like these these sessions
where we're filling in those gaps that
really helps me feel like that
foundation
growing oh no that's good all right well
i mean
i'll be guided by you i mean i did put
together like a
a curriculum and i'm not a stickler for
it i it's just more of like in an order
of
what i think you need in order to
understand something else like otherwise
we'll end up like
wasting a lot of time i'm just trying
for better efficiency not that like
there's anything in it that you're not
gonna understand it's just
like why go too far down an advanced
rabbit hole topic if
you know you didn't build the
fundamentals like i'd rather we get to
like pointers first before we start
talking about
handles for example or map
well we'll leave that over yeah we'll
leave that for another day
oh man we're we're getting into some
serious scotch discussion here huh i
know i'm sorry i love scotch and that's
right you're killing me i you know that
i'm gonna go
my go-to drink i'm sorry like soon yes
and my collection behind me so i usually
i usually only drink scotch
video games because i can have a beer
i mean that's fine but scotch kind of
hits my head a little too fast
so i can have a couple glasses of scotch
and still be extremely good at video
games i cannot have
a couple of glasses of scotch and still
be writing decent
especially if you're learning some new
code too i mean it's it's one thing if
like you're replaying stuff you're
really familiar with but
like this i think a lot of this stuff is
going to be new concept for you coming
from python
so like why impair the brain
yeah yeah i need all the brain cells why
not spend all the brain cells and then
later on impair the brain and have more
fun because you're not trying to learn
something at the same time
exactly and sarah clue has probably
taken like
yeah that's all i'm proud of i'm i'm
proud of you too that's that's
tough first session back after kovid
yeah
man kovitz nasty people please stay home
wear masks be healthy just listen to her
she's
please please she's in my ears so i'm
visually pointing at my headphones but
she's physically located actually let's
see what's that
south i think south's that way so you're
you're that way
yes that away that is south away
wait bananas ew strophium i'm so sorry
that sounds very
sweet i'm sorry i'm one of those freak
people on the planet that
tweets so anything that sounds sweet
no so i feel a little bad i ended up
missing last miles
i saw he had a comment where he was
upset that i was using
care which
oh well if he was still here i would i
would
talk to him about using the unsigned
types and the modern standardized but
um we'll get there we're gonna use we're
using kind of the classic types for now
so
yeah i mean having a signed care is the
default that's like in modern
days that's a little bit crazy for
reasons that we got into in a lot of
detail
which makes sense now i understand which
is great because
a lot of times right now i'm i'm serving
her first very junior data scientist and
so
i want to be able to kind of have that
background they ask me questions i'm not
constantly going like i'll get back to
you
so i like i like having that it makes
sense so if somebody someday ask me
unsigned versus signed cares i'm like i
got you i know now i can explain it sit
down we'll have coffee it's good
yeah yeah no totally i mean i i think
it's i think it's better
model wise to like come through you know
because like if the first version of a
type like
you just saw here with um i don't know
if you saw that in the chat but
strophian was just mentioned this is one
of the modern types
yes i've seen that yep yep um yep this
is
like i think this is a little scary to
look at
if you've never seen types before
like compared to like this line this int
a like this is
this is a lot simpler to look at and
sort of comprehend so
yeah we had to get into a bit about int
and all the other stuff and it's it's
kind of non-standard due to
history but this this version
which is the modern standard that is
totally unambiguous and so that's that's
written
nowadays which is much more actually
it's much better to see in like a c
program but
if you're looking at like older programs
you're going to see stuff that looks
more like this
in fact you used to have to create this
like ewing stuff you know this
these like i think i think it was gcc
that first introduced these but
you know you used to like define this
stuff for doing things
i shouldn't be doing that all right
we're done okay
no we're not going down another rabbit
we're not going down that
oh front line come on python doesn't
have types you could just do whatever
and it just works out
not always true there are type errors no
i i i it's funny because python is
incredibly forgiving like
if there's any interpretation that makes
sense python will give it to you
c on the other hand is much more
unforgiving it's more like
that either compiles or it doesn't and
if it doesn't compile
like i guess that property exists for
python too so
that's a bad example but
yeah i mean the whole notion of duct
typing like is
well i mean you're actually intuitively
familiar with it because you've been
programming in python but
like when we actually start implementing
that kind of thing keep in mind like
something like python is written in c
like it it takes a lot of lines
to add that functionality i can tell you
that much
i bet i mean it's it's so flexible that
it's almost two
no it's it's great but anyway
no no strophium no i'm not showing your
c plus plus
no no i have i have to go to bed friends
i have a very early
well not very some one of them got
canceled but still people want me to be
on camera way too early in the mornings
i i cannot go down rabbit holes of
whatever duck typing is
c plus and things like that so next time
though
you should follow right follow some
coding guy
and you mondays i believe is our yeah
jess
tries to learn c nights
but i do appreciate that yeah i mean
follow the monday sessions are like this
um the other days are uh other stuff
i'll
i don't want to talk too much about it
but basically uh i'm building a version
of
netflix that you can from scratch
so that's so cool i'm sorry
i'm like oh like i i've printed out
every letter of the alphabet you're like
i'm gonna build
netflix like that's so cool hey i'm
doing it in python you could totally
follow along with that ooh
yes okay actually if it's in python i i
haven't i have an
actual i haven't i've tried to make that
as accessible as possible
i was sort of challenged i'm just so you
all know i don't work at netflix i used
to work at netflix i was there for about
six years
and um i was getting a whole bunch of
questions which actually started talking
about bits and bytes and
and how the internet works and data
speeds and the way transfers work and
the way streaming video works because
everyone's like watching streaming video
and they're like
hey how does that work and i'm like uh
you know kind of like this and i started
explaining it
and they were all like no it works this
other way and i was like no it
doesn't at all like that's that's
that's kind of way off and so like one
challenge led to another and then all of
a sudden i was like you know what
why don't we just do a mini series on
how streaming works
like at a really high level and so i
tried to make it as accessible as
possible so
that that meant javascript to me
so that seems to be like the most common
language that i've seen live coded on um
on twitch so but you know because i
couldn't go 100 javascript without
lobotomizing myself i i did the server
stuff in python so
that's that's kind of the split
okay i did not do the are you still
watching feature i do know
godfather exactly who did do that
feature and i'm not giving away the name
of that person so um and which is a
terrible shaming feature
it's not a shaming feature this this
this didn't work at all the way we
thought it was gonna work
that i don't know how much i should say
about that and how much is closely
guarded secret
actually no it's totally not because
it's now user configurable
think i should say no yeah i think you
can turn it off but um
yeah you have control over post right
now i have to go i'm so sorry no
totally fine if you want to go like keep
telling people about netflix i don't
want to like
if you all want to come back uh i'm
doing CSGFlix on wednesday and friday
otherwise come back on monday and we'll
be doing it
we'll be doing c with jess and python
earlier in the day
all right so let's wrap up
let's just call it a day there um so
anyway thank you everybody for the
follows thanks for hanging out thanks
for chatting thanks for
all of these things and jess thank you
for
keeping your mind open and trying to--
it's very difficult so um i appreciate
it all
and chat have a good time and like jess
says stay safe wash your hands stay home
all that stuff
um bye chat get through this yes and bye
everybody