Jump to content

converting a hexadecimal value to an equivaluent decimal....need help


reneeshtk

Recommended Posts

I have to convert a hexa decimal value to a double value in php. I have converted hexadecimal to integer..using function base_convert(). But in this case it not giving me a good result..

 

Examples:

9A99999999193A40  = 26.1 (Approx)

CDCCCCCCCC4C3CC0  = -28.3 (Approx)

 

In this the order may be from back to front. ie..403A19999999999A..

If you have any idea please help.

 

 

Link to comment
Share on other sites

I have to convert a hexa decimal value to a double value in php. I have converted hexadecimal to integer..using function base_convert(). But in this case it not giving me a good result..

 

Examples:

9A99999999193A40  = 26.1 (Approx)

CDCCCCCCCC4C3CC0  = -28.3 (Approx)

 

In this the order may be from back to front. ie..403A19999999999A..

If you have any idea please help.

 

 

hexdec() ....it will not return the required result

Link to comment
Share on other sites

I have to convert a hexa decimal value to a double value in php. I have converted hexadecimal to integer..using function base_convert(). But in this case it not giving me a good result..

 

Examples:

9A99999999193A40  = 26.1 (Approx)

CDCCCCCCCC4C3CC0  = -28.3 (Approx)

 

In this the order may be from back to front. ie..403A19999999999A..

If you have any idea please help.

 

I have converted a integer type hex value by using the follwing code

 

$dat=801A0600

 

$rst=change_to_int($dat);

 

echo $rst;                //It will show 40000...This is the result here I need

 

function change_to_int($dat){

 

$chr_data="";

 

for($i=strlen($dat);$i>0;$i=$i-2){

 

$datac=substr($dat,$i-2,2);

 

$chr_data.=$datac;

 

}

 

return base_convert($chr_data,16,10);

 

}

 

But this is not working in the case of double type values...so please give an idea.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.