Hello. I have searched for a long time now, but i'm stumped. How can I change the string 0xff00ff or whatever to the int 0xff00ff? I tried all of the normal converting methods, but can't seem to get this to work. You guys are my last hope. Thanks.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hello. I have searched for a long time now, but i'm stumped. How can I change the string 0xff00ff or whatever to the int 0xff00ff? I tried all of the normal converting methods, but can't seem to get this to work. You guys are my last hope. Thanks.
How would you do it manually?
Take the digit characters one at a time from the left and get their hex value and use those hex values to build the int value.
First problem is converting a digit character to a hex value. '0' is 0, 'a' is 10
Once you have the hex value then think about how to build the final value given a string of hex values left to right.
Think about how its done with a decimal number. Given "123" you'd get the 1 first and then multiply that by 10 and add the 2 and then multiply that by 10 and add the 3 giving 123.
If you don't understand my answer, don't ignore it, ask a question.