10.12.2012 Views

The Java Language Specification, Third Edition

The Java Language Specification, Third Edition

The Java Language Specification, Third Edition

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CONVERSIONS AND PROMOTIONS Binary Numeric Promotion 5.6.2<br />

// A char&byte is promoted to int&int:<br />

byte b = 0x1f;<br />

char c = 'G';<br />

int control = c & b;<br />

System.out.println(Integer.toHexString(control));<br />

// Here int:float is promoted to float:float:<br />

f = (b==0) ? i : 4.0f;<br />

System.out.println(1.0/f);<br />

}<br />

}<br />

which produces the output:<br />

7<br />

0.25<br />

<strong>The</strong> example converts the ASCII character G to the ASCII control-G (BEL), by<br />

masking off all but the low 5 bits of the character. <strong>The</strong> 7 is the numeric value of<br />

this control character.<br />

DRAFT<br />

O suns! O grass of graves! O perpetual transfers and promotions!<br />

of Grass<br />

111

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!