This week's giveaway is in the
EJB and other Java EE Technologies
forum.
We're giving away four copies of
EJB 3 in Action
and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan online!
See
this thread
for details.
A friendly place for programming greenhorns!
Big Moose Saloon
Search

Java FAQ

Recent Topics

Flagged Topics

Hot Topics

Zero Replies
Register / Login
Win a copy of
EJB 3 in Action
this week in the
EJB and other Java EE Technologies
forum!
JavaRanch
»
Java Forums
»
Certification
»
Programmer Certification (SCJP/OCPJP)
Author
Radix problem
Chandra Bhatt
Ranch Hand
Joined: Feb 28, 2007
Posts: 1707
posted
Apr 19, 2007 00:43:00
0
public class DemoRadix { public static void main(String... args) { Integer i1 = Integer.valueOf("1111",3); Integer i2 = Integer.valueOf("1111",4); out.println(i1); out.println(i2); } } Output: 40 85
I am used to decimal, octal, hexadecimal, binary.
But how to compute when radix is somewhat 4,5 ...
Please help me!
Regards,
cmbhatt
cmbhatt
Steven Young
Ranch Hand
Joined: Apr 11, 2007
Posts: 36
posted
Apr 19, 2007 01:22:00
0
1111 for base 3:
1 * 3 "to the power of" 0 = 1
1 * 3 "to the power of" 1 = 3
1 * 3 "to the power of" 2 = 9 (i.e 3*3)
1 * 3 "to the power of" 3 = 27 (i.e 3*3*3)
So total is 1 + 3 + 9 = 27 = 40
1111 for base 4:
1 * 4 "to power of" 0 = 1
1 * 4 "to power of" 1 = 4
1 * 4 "to power of" 2 = 16 (i.e 4*4)
1 * 4 "to power of" 3 = 64 (i.e 4*4*4)
So total is 1 + 4 + 16 + 64 = 85
Hope this helps. I'm no Mathematics teacher, so this is the best that I can explain.
Chandra Bhatt
Ranch Hand
Joined: Feb 28, 2007
Posts: 1707
posted
Apr 19, 2007 03:12:00
0
Fantastic Steven Young!
Awesome description, even a child "like me" can understand this!
Great Job!
Thankkoo!
cmbhatt
I agree. Here's the link:
http://aspose.com/filetools
subject: Radix problem
Similar Threads
what is the answer?
Integer unboxing and == operator question
Difference
Wrapper equality
Creation of Ineger Wrapper Object
All times are in JavaRanch time: GMT6 in summer, GMT7 in winter