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

Nonrecursive implementations of the min() and floor() method, Write nonrecu...

Write nonrecursive implementations of the min() and floor() methods in BST.java. Make sure to use only one return in your method. Use an insertion sort (discussed in class) to s

Develop a custom android app, Develop a Custom Android App Project Descr...

Develop a Custom Android App Project Description: We want you to construct a custom Android app. Once user downloads the app and upon installation the user gets push notif

How to use dispatchaction, To use the DispatchAction, follow these steps: ...

To use the DispatchAction, follow these steps: ? Make a class that extends DispatchAction (instead of Action) ? In a new class, add a method for each function you need to per

Moving test, After refactor the main class to become abstract class, I want...

After refactor the main class to become abstract class, I want to move test method from tset clas of main class to subclass, how to do that?

How would you interact between servlets and applets? , We may use the java...

We may use the java.net.URL and java.net.URLConnection classes to start a standard HTTP connection and "tunnel" to a Web server. The server then gives this information to the s

I want five page website design, I want five page website design Project...

I want five page website design Project Description: Five page website CMS Front end design Skills required are Graphic Design, Java, HTML, PHP, Website Design

Write code in javascript to display the odd numbers, Write code in JavaScri...

Write code in JavaScript to display the odd numbers among 20 to 100 using FOR statement? Note: No required to write whole HTML program. Just JavaScript code of require elemen

Define network organization and their features, Define network organization...

Define network organization? What are important features of network organization? Network Organization : Network organization is an inter firm organization in which is charac

What is file transfer protocol, What is File Transfer Protocol? This pr...

What is File Transfer Protocol? This protocol is used to upload the files on remote computers. This is used to transfer files among computer on TCP/IP network e.g. internet and

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