Explain arithmetic promotion and binary operations, JAVA Programming

Assignment Help:

Explain Arithmetic Promotion and Binary Operations?

An int divided through an int is an int, and a double divided by a double is a double, but what about an int divided by a double or a double divided by an int? When doing arithmetic on not like types Java tends to widen the types includes so as to prevent losing information. After all 3 * 54.2E18 will be a perfectly valid double but much too big for any int.

The primary rule is that if either of the variables in a binary operation (addition, multiplication, subtraction, addition, remainder) are doubles then Java treats both values as doubles. If neither value is a double but one is a float, then Java treats both values as floats. If neither is a float or a double but one is a long, then Java treats both values as longs. At last if there are no doubles, floats or longs, then Java treats both values as an int, even if there aren't any ints in the equation. Thus the result will be a double, float, long or int depending on the kinds of the arguments.


Related Discussions:- Explain arithmetic promotion and binary operations

State the java virtual machine and runtime environment, Java Virtual Machin...

Java Virtual Machine & Runtime Environment Basic Concept When you write a program in C++ it's called source code. C++ compiler converts this source code into the machine c

Use the constructor, Can we use the constructor, instead of init(), to init...

Can we use the constructor, instead of init(), to initialize servlet? Ans) Yes. Of course you can use the constructor instead of init(). There's nothing to stop you. But you sho

What are logic- or time-bombs, What are Logic- or Time-Bombs ? It execu...

What are Logic- or Time-Bombs ? It execute the payload while predetermined event occurs. For instance use kind's particular phrase and particular data is reached.

Type of messaging is given by jms, Point-to-Point : gives a traditional qu...

Point-to-Point : gives a traditional queue based mechanism where the client application forwards a message through a queue to typically one receiving client that accepts messages

Threads, programming challenges

programming challenges

Enumerate the java program development and execution steps, Java Program De...

Java Program Development and Execution Steps Java program normally go through five phases. These are 1. Edit, 2. Compile, 3. Load, 4. Verify and 5. Execute Co

Explanation of the inputstream with suitable diagrams, Problem 1) Descr...

Problem 1) Describe the concept of interfaces in Java with a suitable example for the same Explanation of the concept of interfaces with example 2) Describe the Inp

Describe about applet security, Describe about Applet Security? The pos...

Describe about Applet Security? The possibility of surfing the Net, wandering across a random page, playing an applet and catching a virus is a fear in which has scared several

Java pass arguments by value or reference, Does Java pass arguments by valu...

Does Java pass arguments by value or reference? Ans) Pass by value. 1. When passing primitives, it going a copy of the variable to the method. Any change made in the method d

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd