This week's giveaway is in the
Android
forum.
We're giving away four copies of
Android Security Essentials Live Lessons
and have Godfrey Nolan 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
Android Security Essentials Live Lessons
this week in the
Android
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
subject: Radix problem
Similar Threads
Creation of Ineger Wrapper Object
Wrapper equality
what is the answer?
Difference
Integer unboxing and == operator question
All times are in JavaRanch time: GMT6 in summer, GMT7 in winter