# 7.2 Ap0020: self-assessment, assignment and arithmetic operators  (Page 7/11)

 Page 7 / 11

C. -0.010999999999999996

## Explanation 12

Modulus operator can be used with floating types

In this case, the program returns the remainder that would be produced by dividing a double value of -0.11 by a double value of 0.033 and terminating thedivide operation at the beginning of the fractional part of the quotient.

Say that again

Stated differently, the result of the modulus operation is the remainder that results after

• subtracting the right operand from the left operand an integral number of times, and
• terminating the repetitive subtraction process when the result of the subtraction is less than the right operand

Modulus result is not exact

According to my hand calculator, taking into account the fact that the left operand is negative, this operation should produce a modulus result of-0.011. As you can see, the result produced by the application of the modulus operation to floating types is not exact.

B. Runtime Error

## Explanation 11

Integer modulus involves integer divide

The modulus operation with integer operands involves an integer divide.

Therefore, it is subject to the same kind of problem as an ordinary integer divide when the right operand has a value of zero.

Program produces a runtime error

In this case, the program produced a runtime error that terminated the program. The error produced by JDK 1.3 is as follows:

 ```Exception in thread "main" java.lang.ArithmeticException: / by zero at Worker.doMod(Ap020.java:14)at Ap020.main(Ap020.java:6)```

Dealing with the problem

As with integer divide, you can either test the right operand for a zero value before performing the modulus operation, or you can deal with the problemafter the fact using try-catch.

D. -2

## Explanation 10

What is a modulus operation?

In elementary terms, we like to say that the modulus operation returns the remainder that results from a divide operation.

In general terms, that is true.

Some interesting behavior

However, the modulus operation has some interesting behaviors that are illustrated in this and the next several questions.

This program returns the modulus of -11 and 3, with -11 being the left operand.

What is the algebraic sign of the result?

Here is a rule:

The result of the modulus operation takes the sign of the left operand, regardless of the sign of the quotient and regardless of the sign of theright operand. In this program, that produced a result of -2.

Changing the sign of the right operand would not have changed the sign of the result.

Exercise care with sign of modulus result

Thus, you may need to exercise care as to how you interpret the result when you perform a modulus operation having a negative left operand.

C. Infinity

## Explanation 9

Floating divide by zero

This program attempts to divide the double value of 11 by the double value of zero.

No runtime error with floating divide by zero

In the case of floating types, an attempt to divide by zero does not produce a runtime error. Rather, it returns a value that the println method interprets and displays as Infinity.

Application of nanotechnology in medicine
what is variations in raman spectra for nanomaterials
I only see partial conversation and what's the question here!
what about nanotechnology for water purification
please someone correct me if I'm wrong but I think one can use nanoparticles, specially silver nanoparticles for water treatment.
Damian
yes that's correct
Professor
I think
Professor
what is the stm
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
Rafiq
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
Damian
How we are making nano material?
what is a peer
What is meant by 'nano scale'?
What is STMs full form?
LITNING
scanning tunneling microscope
Sahil
how nano science is used for hydrophobicity
Santosh
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
Rafiq
what is differents between GO and RGO?
Mahi
what is simplest way to understand the applications of nano robots used to detect the cancer affected cell of human body.? How this robot is carried to required site of body cell.? what will be the carrier material and how can be detected that correct delivery of drug is done Rafiq
Rafiq
if virus is killing to make ARTIFICIAL DNA OF GRAPHENE FOR KILLED THE VIRUS .THIS IS OUR ASSUMPTION
Anam
analytical skills graphene is prepared to kill any type viruses .
Anam
what is Nano technology ?
write examples of Nano molecule?
Bob
The nanotechnology is as new science, to scale nanometric
brayan
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Damian
Is there any normative that regulates the use of silver nanoparticles?
what king of growth are you checking .?
Renato
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
why we need to study biomolecules, molecular biology in nanotechnology?
?
Kyle
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
why?
what school?
Kyle
biomolecules are e building blocks of every organics and inorganic materials.
Joe
anyone know any internet site where one can find nanotechnology papers?
research.net
kanaga
sciencedirect big data base
Ernesto
Introduction about quantum dots in nanotechnology
hi
Loga
what does nano mean?
nano basically means 10^(-9). nanometer is a unit to measure length.
Bharti
Got questions? Join the online conversation and get instant answers! By OpenStax By Anonymous User By OpenStax By Ryan Lowe By Rebecca Butterfield By David Corey By Janet Forrester By Naveen Tomar By Stephen Voron By Madison Christian