ShmoopTube

Where Monty Python meets your 10th grade teacher.

Search Thousands of Shmoop Videos

Computer Science: Doubles and Ints 17 Views


Share It!


Description:

Doubles and ints. At first glance, it may look like this video will be about baseball and football statistics. But they're actually computer science terms, referring to basic data structures that... hold numbers. Awww. Feel the love.

Language:
English Language

Transcript

00:00

doubles in ints. well, this is Macon the month, life's pretty good in

00:08

his closet full of clothes but Macon's noticed lately that the owners of his [moth on sweater]

00:13

closet don't really know how to keep things organized. it's hard to enjoy a

00:18

dinner of pink wool cardigan on top of a shoe organizer. make it a sophisticated

00:24

he likes his meals right off the rack. why is he such an organization nut? well

00:30

because he's a computer scientist moth. and when you get right down to it a

00:34

closet is a lot like a data structure in computer science, or a piece of memory

00:40

set aside to hold some specific amount of data. just like the different spaces

00:45

in the closet different types of data structures need different amounts of [closet organized into sections]

00:49

space. you can't exactly stuff a ball gown into a shoebox after all ,and you

00:54

definitely can't stuff an object into an in.t what in the world is an INT? well one

00:59

of these guys- we'll get to it in a sec. all right now if we want to complete

01:03

this metaphor Macon's code closet would look something like this. we aren't gonna

01:09

focus on those sweater shoes and whatever random things fit into

01:12

miscellaneous. well today's all about shirts and pants or ints and doubles.

01:17

well ints and doubles are basic data structures in computer science and all

01:21

they do is hold numbers. Computers love numbers way more than making love's [numbers crowded together]

01:25

noshing on our mom's most expensive casual wool scarf. because they store

01:31

numbers in memory computers can only set aside so much space for each number.

01:36

which means that numbers can only be so big or so small which is part of the

01:40

reason java has different memory types. numbers can also either have a decimal

01:45

point or not and well first up integers. integers are usually considered the most [decimals pictured]

01:51

important number type according to computers. these are the same as integers

01:55

in math class. positive and negative numbers that don't have any decimals

02:00

attached the integers usually take up either two

02:04

or four bytes in computer memory which means that they can get up to either

02:08

about thirty two thousand or two million. in Java we're working with four byte.

02:13

versions well you can make an int by writing int variable name equals the

02:19

number and Java is gonna take that number without the decimals into the [int variables listed]

02:23

four bytes of memory it uses for any integer. well try to assign a number like

02:27

four million to an int and you'll get nothing but errors. well if you need more

02:32

space doubles are for both you and Macon. these number types like pants take up

02:39

way more space than int -double the space by some counts

02:43

well doubles need to be huge because they handle floating-point numbers, which

02:49

means decimal numbers, in the math case. well doubles can be written in stored

02:54

like this- another variable is set to the double value of six. well all that extra

03:01

space makes those variables nice and wrinkle free which means better grub for [clothes in boxes]

03:06

Macon. so if doubles can store so much more than ants why even bother with

03:12

integers at all? when we've got two reasons .first only use what you need

03:17

when making flies into a new closet and sees a giant buffet of t-shirts and

03:22

jumpsuits, well he needs to be careful only to eat what he needs or the owners

03:27

of the closet will get wise and decide to fumigate ,making wants to live and

03:32

procreate you know giggity, so what well he needs to eat a normal amount .in the [ moth in a closet]

03:37

same way you should only use the amount of space you need. if you're saving

03:42

someone's age, well you probably only need intz unless that person is under

03:47

ten and really wants you to remember that they're actually already halfway to

03:50

their next birthday. all right well even if you do need

03:53

numbers with decimals sometimes it's better to use integers anyway .if you

03:57

remember from math class decimal point values are equal to fractions. computers

04:01

don't use decimals which is base 10. they use binary .when converting between [equations]

04:07

decimal and binary you can sometimes lose values so the result isn't exactly

04:12

the same as what you've wanted it to be. take money for example

04:15

well technically doubles make more sense because there's a decimal point but

04:20

because we know that we can only break a dollar down into hundreds which are

04:24

pennies by the way well we can just represent it in ints so that we don't end

04:29

up losing any valuable Linkens. all right well a couple of pennies might not sound

04:33

like much to you but to Macon in well that's a year supply of food. someone who [moth near coat]

04:38

doesn't decide to go on a silk only diet.

Up Next

Computer Science: Setting Up Your Environment
19 Views

Just as you move your furniture into a new house before spending the night, you’ve got to spend a little time setting up your environment when yo...

Related Videos

Jane Eyre Summary
123033 Views

When you're about to marry the love of your life, not many things could stop you. However, finding out that your future hubby is keeping his crazy...

What is Shmoop?
91405 Views

Here at Shmoop, we work for kids, not just the bottom line. Founded by David Siminoff and his wife Ellen Siminoff, Shmoop was originally conceived...

ACT Math 4.5 Elementary Algebra
492 Views

ACT Math: Elementary Algebra Drill 4, Problem 5. What is the solution to the problem shown?

AP English Literature and Composition 1.1 Passage Drill 1
1039 Views

AP® English Literature and Composition Passage Drill 1, Problem 1. Which literary device is used in lines 31 to 37?