>> Hey friends. In our last video,
we talked about numbers and integers,
and now we're going to talk about integer precision,
because earlier, we divided 11 by 3,
and we got the number three and that upsets me.
>> Right.
>> I want to know where my remainder is.
So we're moving on to the next bit
of the tutorial which is integer precision,
and they told me that it truncated the results.
>> Truncated. Now that's a vocab word.
That basically just mean that we lost the remainder.
>> So it's gone which is sad.
But what we're going to do is we're
going to use a different operator,
not the division operator
but we're going to use the modulo operator.
So in e, I should get my remainder.
Okay, so it's 11 divided by 3,
the remainder in this case is 2 because
9 divided by 3 divides evenly,
the remainder is 2.
So that's interesting. That didn't give
me a decimal or a fraction.
It gave me the quotient and the remainder.
>> All right. Just as if you had worked it out by hand,
the remainder would have been two at the end.
>> Now in Math though,
integers can go infinitely though.
But in C Sharp, there's a minimum and
a maximum size for an integer.
>> Okay, and that's just limited to how much
the computer can actually keep in memory in this value type,
because as we said before,
integers actually do have
constraints when you put them into a computer.
So with Math on paper,
it can often be very theoretical when you write it down,
I could have just an infinite number.
With computers, we have real-world constraints for how
much we can actually save into this processor.
>> Okay, so let's go and copy this sample and say int.MaxValue.
Just like we said string.Length and it had a property,
integers have the properties as well,
like MinValue and MaxValue,
and then we'll do the same string stuff
that we did in a previous video,
and we'll say let's see the min and the max.
>> Yeah.
>> Oh, my goodness.
>> It's a pretty big number.
>> It looks like negative two billion?
>> About that.
>> Yeah.
>> It sounds about, right?
>> Yeah, two billion and a couple of 100 million between friends.
It's interesting, it's negative to positive.
So it's a whole, it's a four billion wide range,
but what if we may be added three to the max.
>> Yeah, let's see what happens.
>> Let's take max. So we have two billion,
147 million and we're going to add 3 to it.
Well, that's definitely weird.
We said max value plus three.
It flipped the odometer.
>> So now instead of going like the last few numbers are 647,
so it could have gone to 650,
it actually just became negative.
>> So this addition operation overflowed.
It's like when you have an old time odometer
where it goes all the way to zero and then keeps going.
>> It just flipped over. Yeah.
>> So it erupted, we were on max.
Like to be clear,
we were at the maximum number which is super
high and now we're at the super tiny number.
So something you ought to think about
when you're dealing with numbers that are really really,
really huge and maybe there are
other types with different limits that might be bigger.
Like instead of an integer a long or something like that.
>> Yeah. So you can definitely use larger numbers.
It's just at the get-go,
you have to make sure you tell your computer that you're going to
go above the integer max
so you might want to use a long in that case.
>> So let's go to the next one.
So a numeric type that lets
you do a really big number would be a double,
and doubles are cool not just because they're
giant but they're also precise.
They let you do things with
decimal points and so far we haven't seen any decimals yet.
So let's do the exact same thing.
>> The doubles. There we go.
There's our remainder, we got 4.5.
>> All right, and that's a little bit more intuitive.
It includes the decimal point.
So I didn't have to go and do
that modulo stuff which I found a little bit frustrating.
Let's try a more complicated example with doubles.
Here we go, 5.25. That's good.
So what is it double MinValue and MaxValue.
>> Yeah.
>> Is it going to be two billion?
I don't know. Holy crap.
>> So we've got e.
>> To 308th power or whatever.
>> Yeah. So much, much larger that what integer are limited.
>> All right. So that is scientific notation and that number to
the right has a power of 10.
Has an expression to the power of 10.
So basically a lot more to put it in some concern.
>> So much more that needs to be printed out
in scientific notation. Cool.
>> This is an interesting one too that you want to think about
because decimals and fractions are slightly different.
So if I divide 1 by 3,
you'd expect that we'd get one-third.
But instead, I get 0.3333333 which
is not exactly the same as
one-third but it's close. It's repeating.
>> Yeah, it's another case where if you had it on paper,
the theory of math is a lot more exact.
But again, computers are in the real world so it has to have
some concrete representation of
this number which means ultimately,
it's rounded at what is that?
Twelve decimal places, something like that.
>> All right. So we've talked about small numbers like
integers and really big numbers like doubles.
Let's take a break and we'll come back and
talk about another kind of number in C Sharp.