<< Chapter < Page Chapter >> Page >

Other data types involve numbers with fractional parts. We generally refer to these types as floating-point types, because a decimal point can float back and forth, separating the whole-number part from the fractional part. (After a while, we get lazy and refer to these simply as floating types.)

An example of integer and floating-point types

The scenario in Figure 1 illustrates integer and floating-point types.

Figure 1 . Calculating the number of cans of paint to purchase.

Consider the problem of determining the number of cans of paint that must be purchased in order to paint all 15 tables in a restaurant.

The number of tables is an integer type. We don't want to paint 14.6 tables or 15.7 tables. We want to paint exactly 15 tables. (We don't want to have a fractional part of a table left unpainted.)

We know that one can of paint will cover 3.6 tables. The number of tables that can be painted with one can of paint is a floating-point value because it contains a whole-number part and a fractional part.

A little arithmetic tells us that 4.167 cans of paint will be required to paint all 15 tables. This is also a floating-point value, because it has a whole-number part and a fractional part.

However, the man at the hardware store is unwilling to sell us 4.167 cans of paint. He requires us to specify the number of cans of paint as an integer value. In this case, we will need to purchase 5 cans of paint in order to have enough paint available to paint all 15 tables, with a little paint left over.

Other types of data

Although all data in a computer is stored in numeric format, some data types conceptually have nothing to do with numeric values, but deal only with the concept of true or false or with the concept of the letters of the alphabet and the punctuation characters. I will have more to say about these types later.

Type specifications

For every different type of data used with a particular programming language, there is a specification somewhere that defines two important characteristics of the type:

  1. The set of all possible data values that can be stored in an instance of the type. (We will learn more about the concept of an instance shortly.)
  2. The operations that you can perform on that instance alone, or in combination with other instances. (For example, operations include addition, subtraction, multiplication, division, etc.)

What do I mean by instance ?

Think of the type specification as being analogous to the plan or blueprint for a model airplane. Assume that you build three model airplanes from the same set of plans. You will have created three instances of the single set of plans.

We might say that an instance is the physical manifestation of a plan or a type.

An example, the short data type

There is a data type in Java, C++, and C# known as short . If you have an instance of the short type in Java, the set of all possible values that you can store in that instance is the set of all whole-numbers ranging from -32,768 to +32,767.This constitutes a set of 65,536 different values, including the value zero.

Questions & Answers

what is defense mechanism
Chinaza Reply
what is defense mechanisms
Chinaza
I'm interested in biological psychology and cognitive psychology
Tanya Reply
what does preconceived mean
sammie Reply
physiological Psychology
Nwosu Reply
How can I develope my cognitive domain
Amanyire Reply
why is communication effective
Dakolo Reply
Communication is effective because it allows individuals to share ideas, thoughts, and information with others.
effective communication can lead to improved outcomes in various settings, including personal relationships, business environments, and educational settings. By communicating effectively, individuals can negotiate effectively, solve problems collaboratively, and work towards common goals.
it starts up serve and return practice/assessments.it helps find voice talking therapy also assessments through relaxed conversation.
miss
Every time someone flushes a toilet in the apartment building, the person begins to jumb back automatically after hearing the flush, before the water temperature changes. Identify the types of learning, if it is classical conditioning identify the NS, UCS, CS and CR. If it is operant conditioning, identify the type of consequence positive reinforcement, negative reinforcement or punishment
Wekolamo Reply
please i need answer
Wekolamo
because it helps many people around the world to understand how to interact with other people and understand them well, for example at work (job).
Manix Reply
Agreed 👍 There are many parts of our brains and behaviors, we really need to get to know. Blessings for everyone and happy Sunday!
ARC
A child is a member of community not society elucidate ?
JESSY Reply
Isn't practices worldwide, be it psychology, be it science. isn't much just a false belief of control over something the mind cannot truly comprehend?
Simon Reply
compare and contrast skinner's perspective on personality development on freud
namakula Reply
Skinner skipped the whole unconscious phenomenon and rather emphasized on classical conditioning
war
explain how nature and nurture affect the development and later the productivity of an individual.
Amesalu Reply
nature is an hereditary factor while nurture is an environmental factor which constitute an individual personality. so if an individual's parent has a deviant behavior and was also brought up in an deviant environment, observation of the behavior and the inborn trait we make the individual deviant.
Samuel
I am taking this course because I am hoping that I could somehow learn more about my chosen field of interest and due to the fact that being a PsyD really ignites my passion as an individual the more I hope to learn about developing and literally explore the complexity of my critical thinking skills
Zyryn Reply
good👍
Jonathan
and having a good philosophy of the world is like a sandwich and a peanut butter 👍
Jonathan
generally amnesi how long yrs memory loss
Kelu Reply
interpersonal relationships
Abdulfatai Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Ap computer science a, clarification of the java subset. OpenStax CNX. Oct 03, 2015 Download for free at https://legacy.cnx.org/content/col11279/1.5
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Ap computer science a, clarification of the java subset' conversation and receive update notifications?

Ask