5.1.3
Narrowing Primitive Conversions
CONVERSIONS AND PROMOTIONS
sent type
T
. In addition to a possible loss of information about the magnitude of
the numeric value, this may cause the sign of the resulting value to differ from the
sign of the input value.
A narrowing conversion of a character to an integral type
T
 likewise simply
discards all but the
n
lowest order bits, where
n
is the number of bits used to rep 
resent type
T
. In addition to a possible loss of information about the magnitude of
the numeric value, this may cause the resulting value to be a negative number,
even though characters represent 16 bit unsigned integer values.
A narrowing conversion of a floating point number to an integral type
T
 takes
two steps:
1. In the first step, the floating point number is converted either to a
long
, if
T
 is
long
, or to an
int
, if
T
 is
byte
,
short
,
char
, or
int
, as follows:
N
If the floating point number is NaN ( 4.2.3), the result of the first step of the
conversion is an
int
 or
long 0
.
N
Otherwise, if the floating point number is not an infinity, the floating point
value is rounded to an integer value
V
, rounding toward zero using IEEE
754 round toward zero mode ( 4.2.3). Then there are two cases:
O
If
T
 is
long
, and this integer value can be represented as a
long
, then the
result of the first step is the
long
 value
V
.
O
Otherwise, if this integer value can be represented as an
int
, then the
result of the first step is the
int
 value
V
.
N
Otherwise, one of the following two cases must be true:
O
The value must be too small (a negative value of large magnitude or nega 
tive infinity), and the result of the first step is the smallest representable
value of type
int
 or
long
.
O
The value must be too large (a positive value of large magnitude or posi 
tive infinity), and the result of the first step is the largest representable
value of type
int
 or
long
.
2. In the second step:
N
If
T
 is
int
 or
long
, the result of the conversion is the result of the first step.
N
If
T
 is
byte
,
char
, or
short
, the result of the conversion is the result of a
narrowing conversion to type
T
 ( 5.1.3) of the result of the first step.
56






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