how to read Double value from Binary File By php

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • nooy66@gmail.com

    how to read Double value from Binary File By php

    I need to read value type double form my binary file.
    When i use Hex Workshop software read my binary file.
    i have data 8 bytes :

    hex = 3131 3131 3131 3140
    string = 1111111@
    Float = 2.5784852e-009
    Double = 17.192157

    When i use php to read file by code:

    $s = fread($handle , 8);
    $val = hexdec(swap_hex (bin2hex($s)))) ;

    now i have float value = 2.5784852e-009 but i want Double value.
    Somebody can help me please....

  • Ewoud Dronkert

    #2
    Re: how to read Double value from Binary File By php

    nooy66@gmail.co m wrote:[color=blue]
    > I need to read value type double form my binary file.
    > When i use Hex Workshop software read my binary file.
    > i have data 8 bytes :
    >
    > hex = 3131 3131 3131 3140
    > string = 1111111@
    > Float = 2.5784852e-009
    > Double = 17.192157[/color]

    print_r(unpack( 'd', '1111111@'));

    does it for me. See http://php.net/unpack

    --
    E. Dronkert

    Comment

    Working...