4.2.4
Floating Point Operations
TYPES, VALUES, AND VARIABLES
4.2.4   Floating Point Operations
Java provides a number of operators that act on floating point values:
The comparison operators, which result in a value of type
boolean
:
N
The numerical comparison operators
<
,
<=
,
>
, and
>=
( 15.19.1)
N
The numerical equality operators
==
 and
!=
 ( 15.20.1)
The numerical operators, which result in a value of type
float
 or
double
:
N
The unary plus and minus operators
+
and
( 15.14.3,  15.14.4)
N
The multiplicative operators
*
,
/
, and
%
( 15.16)
N
The additive operators
+
 and
 ( 15.17.2)
N
The increment operator
++
, both prefix ( 15.14.1) and postfix ( 15.13.2)
N
The decrement operator
  
, both prefix ( 15.14.2) and postfix ( 15.13.3)
The conditional operator
? :
 ( 15.24)
The cast operator, which can convert from a floating point value to a value of
any specified numeric type ( 5.4,  15.15)
The string concatenation operator
+
 ( 15.17.1), which, when given a
String
operand and a floating point operand, will convert the floating point operand
to a
String
 representing its value in decimal form (without information loss),
and then produce a newly created
String
 by concatenating the two strings
Other useful constructors, methods, and constants are predefined in the classes
Float
 ( 20.9),
Double
 ( 20.10), and
Math
 ( 20.11).
If at least one of the operands to a binary operator is of floating point type,
then the operation is a floating point operation, even if the other is integral.
If at least one of the operands to a numerical operator is of type
double
, then
the operation is carried out using 64 bit floating point arithmetic, and the result of
the numerical operator is a value of type
double
. (If the other operand is not a
double
, it is first widened to type
double
 by numeric promotion ( 5.6).) Other 
wise, the operation is carried out using 32 bit floating point arithmetic, and the
result of the numerical operator is a value of type
float.
If the other operand is
not a
float
, it is first widened to type
float
 by numeric promotion.
Operators on floating point numbers behave exactly as specified by IEEE 754.
In particular, Java requires support of IEEE 754
denormalized
 floating point num 
bers and
gradual underflow
, which make it easier to prove desirable properties of
particular numerical algorithms. Floating point operations in Java do not  flush to
zero  if the calculated result is a denormalized number.
34






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved