Big Moose Saloon
 Search | Java FAQ | Recent Topics Register / Login Today (12/10) is CodeRanch Day in Manning's Countdown to 2014. Use discount code crdotd14 all month for 50% off every deal. CodeRanch Day is 50% off our pick of books: Secrets of the JavaScript Ninja; The Well-Grounded Java Developer; Java 8 Lambdas in Action; HTML5 in Action; The Responsive Web; and Java Persistence with Hibernate

# numeric conversions

Otto Deckelman
Ranch Hand

Joined: Mar 28, 2001
Posts: 30
What does FFFF FFF1 convert to in base 10?
Jamal Hasanov
Ranch Hand

Joined: Jan 08, 2002
Posts: 411
Hi, Otto
FFFF FFF1
7654 3210
FFFFFFF1 = 15*16^7+15*16^6+15*16^5+15*16^4+15*16^3+15*16^2+15*16^1+1*16^0
Jamal Hasanov
www.j-think.com
Brian Lugo
Ranch Hand

Joined: Nov 10, 2000
Posts: 165
I believe it converts to -15 in base 10.
Brian
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

Originally posted by Brian Lugo:
I believe it converts to -15 in base 10.
Brian

Doesn't it depend if the number signed or unsigned?
Brian Lugo
Ranch Hand

Joined: Nov 10, 2000
Posts: 165
Thats very true Jessica, I assumed the number was a 32 bit signed integer (in Java) and not 32 bit float.
Brian
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by Jessica Sant:

Doesn't it depend if the number signed or unsigned?

How a number is converted from Hex to Decimal is dependent upon if the number is signed or unsigned and also if the number is an integer value or a floating point value.
Obviously, whether the value is signed or unsigned lets us know whether the most significant bit is a data bit or a sign bit.
If you're dealing with a floating point value, part of that value is interpreted as an exponent. You can check out this thread for details about this.
However, for the exam, you'll probably be safe knowing how to convert signed ints between the various bases (dec, hex, oct, bin).
Corey

SCJP Tipline, etc.

I agree. Here's the link: http://aspose.com/file-tools

subject: numeric conversions