I have a strange stiuation here.
I need to use a float number(because it is 20 or more, digits long), then calculate hexadecimal of this number, and then save the result in an integer and use that as a key.
Some how the code I posted was wrong.
float x= 99999999999999999999f; //20 9's
String s = Float.toHexString(x);
Thanks for your reply. I have checked on the BigDecimal class before posting but dont want to write seperate code just to calculate Hexadecimal of a number.
looking for some java API which can do this for me.
Thanks for your reply.
Both Sound good but as I mentioned in my first post, they dont give back exact Hex string. Float gives 0x1.5af1d8p66 and I was unable to convert it into clean Hexadecimal string.
As soon as I thought I have got this done someone pointed out the mistake.
When I give 256.0f, The answer I expect is 100 and not 4380000.
When I try String s = String.format("%x",256L); I get the required result,
But this can only work for long data type. This fails as soon as I give more than 19 digits and I need to work with 20 digita.
Can you let me know how to work through this.
A quick hint by all is very much appretiated as this is bocomming a priprity now.