Lecture041 if-else - Lecture 7 -- 1 Computer Science I -...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Lecture 7 -- 1 Computer Science I - Martin Hardwick Other Types Of Data Variables of type short use half a word (16 bits) to represent a value. everything else is the same as int range of values: -32,768 through 32,767 Variables of type float use one word (32 bits) to represent a value instead of the two used by a double. the extra bits are taken from the mantissa (number of digits) A float has about 7 digits of accuracy A double has about 14 digits of accuracy Both can represent the same huge range (exponent) Lecture 7 -- 2 Computer Science I - Martin Hardwick More types An unsigned integer does not use a bit for the sign. An unsigned integer can be slightly larger than an integer but cannot be negative unsigned positive; A character variable is used to store a single character char letter = A; Like float and short, char variable is not used much anymore. We will use it occasionally. Instead we use String objects (much more on this later). Lecture 7 -- 3 Computer Science I - Martin Hardwick Types we use Integer for ordinary numbers Double for floating points numbers String for string data (more later) Bool for logical values (more later) And in a few lectures we will begin to define our own data types. The types provided by the language are also known as the primitive types The types that we define are also known as defined types. Good programming requires good data types Lecture 7 -- 4 Computer Science I - Martin Hardwick Converting between types For the primitive types conversion is usually implicit...
View Full Document

Page1 / 11

Lecture041 if-else - Lecture 7 -- 1 Computer Science I -...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online