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.

 

 

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

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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.