About the function double-java


		double d = 5/10;

The result of d is 0.0. Not 0.5. This is because both literals are int type.


		int d = 5/10;

Since the result of is 0, it is cast to double type and becomes 0.0.

Since the calculation result is int in the calculation between int types Make either one a double literal.


		double d = 5.0/10;
		double d = 5/10.0;

Result is It will be 0.5.

Recommended Posts

About the function double-java
[Rails] About the Punk List function
About the method
About the package
Output about the method # 2
About the StringBuilder class
Commentary: About the interface
About the asset pipeline
About the ternary operator
Let's understand the function!
About the length method
About the Kernel module
About the authenticate method.
About the map method
About the ancestors method
[Output] About the database
About the [ruby] operator
About the to_s method.
About the handling of Null
About specifying the JAXRS path
Output about the method Part 1
about the where method (rails)
A note about the scope
About the description of Docker-compose.yml
About the File :: Stat class
About the same and equivalent
Rails ~ Understanding the message function ~
About the Android life cycle
About the explanation about functional type
About immediate comment update function
About the programming language Crystal
Consideration about the times method
About adding a like function
About the function of Spring Boot due to different versions
A note about the seed function of Ruby on Rails
About the behavior of ruby Hash # ==
About the language to be learned
About the basics of Android development
User evaluation using the like function
About the equals () and hashcode () methods
About the symbol <%%> in Rails erb
About the information sharing app band
About error handling of comment function
[Rails] About implementation of like function
About the current development environment (Java 8)
A murmur about the utility class
About the role of the initialize method
Think about the 7 rules of Optional
About =
How to add the delete function
Summary about the introduction of Device
About the log level of java.util.logging.Logger
About the version of Docker's Node.js image
Guess about the 2017 Java Persistence Framework (3) Reladomo
Check once again about the OpenSSL command
[Java] How to use the hasNext function
What is testing? ・ About the importance of testing
[Swift] A note about function and closure
About the procedure for java to work
About the new Java release model @ Seki Java (2018/07/20)
About the operation of next () and nextLine ()