Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default fwrite int or float

    Is there some easy way to fwrite a 32 bit int or float?

    --
    Ted Huntington
    Programmer Analyst I
    Main Library
    University of California, Irvine
    PO Box 19557
    Irvine, CA 92623-9557

    Phone Bus Off 949 824 8926
    Phone MRC 949 824 1674
    emesg: [email]thunting@uci.edu[/email]
    webpage: [url]http://business.lib.uci.edu/webpages/ted.htm[/url]
    "Stop violence, teach science."


    Ted Huntington Guest

  2. Similar Questions and Discussions

    1. fwrite() help needed
      I am trying to write to a .rtf file form a php page. I can create a temp rtf file based on a template but i can only change one item on the page....
    2. #25562 [Opn->Bgs]: Float to String to Float conversion error
      ID: 25562 Updated by: helly@php.net Reported By: daseymour at 3hc dot org -Status: Open +Status: ...
    3. #25562 [NEW]: Float to String to Float conversion error
      From: daseymour at 3hc dot org Operating system: and PHP version: 4.3.3 PHP Bug Type: Math related Bug description: Float...
    4. Is fwrite atomic or not?
      I've seen answers both ways in the archive of this list, and I wonder what is true. Suppose I open a file in append mode - like a log file. Two...
    5. fwrite problem
      Hi all, I am writing a small script which will run on solaris. I want to get the IP address and write it to a file log.dat. File is created fine...
  3. #2

    Default Re: [PHP] fwrite int or float

    ok I see to use the "pack" command, but now how do I format to 32 bit
    little endian?


    Ted Huntington wrote:
    > Is there some easy way to fwrite a 32 bit int or float?
    >
    > --
    > Ted Huntington
    > Programmer Analyst I
    > Main Library
    > University of California, Irvine
    > PO Box 19557
    > Irvine, CA 92623-9557
    >
    > Phone Bus Off 949 824 8926
    > Phone MRC 949 824 1674
    > emesg: [email]thunting@uci.edu[/email]
    > webpage: [url]http://business.lib.uci.edu/webpages/ted.htm[/url]
    > "Stop violence, teach science."
    >
    > --
    > PHP General Mailing List ([url]http://www.php.net/[/url])
    > To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]
    --
    Ted Huntington
    Programmer Analyst I
    Main Library
    University of California, Irvine
    PO Box 19557
    Irvine, CA 92623-9557

    Phone Bus Off 949 824 8926
    Phone MRC 949 824 1674
    emesg: [email]thunting@uci.edu[/email]
    webpage: [url]http://business.lib.uci.edu/webpages/ted.htm[/url]
    "Stop violence, teach science."


    Ted Huntington Guest

  4. #3

    Default Re: [PHP] fwrite int or float

    I should have type "signed 32 bit little endian" and little endian float.

    Ted Huntington wrote:
    > ok I see to use the "pack" command, but now how do I format to 32 bit
    > little endian?
    >
    > Ted Huntington wrote:
    >
    > > Is there some easy way to fwrite a 32 bit int or float?
    > >
    > > --
    > > Ted Huntington
    > > Programmer Analyst I
    > > Main Library
    > > University of California, Irvine
    > > PO Box 19557
    > > Irvine, CA 92623-9557
    > >
    > > Phone Bus Off 949 824 8926
    > > Phone MRC 949 824 1674
    > > emesg: [email]thunting@uci.edu[/email]
    > > webpage: [url]http://business.lib.uci.edu/webpages/ted.htm[/url]
    > > "Stop violence, teach science."
    > >
    > > --
    > > PHP General Mailing List ([url]http://www.php.net/[/url])
    > > To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]
    >
    > --
    > Ted Huntington
    > Programmer Analyst I
    > Main Library
    > University of California, Irvine
    > PO Box 19557
    > Irvine, CA 92623-9557
    >
    > Phone Bus Off 949 824 8926
    > Phone MRC 949 824 1674
    > emesg: [email]thunting@uci.edu[/email]
    > webpage: [url]http://business.lib.uci.edu/webpages/ted.htm[/url]
    > "Stop violence, teach science."
    >
    > --
    > PHP General Mailing List ([url]http://www.php.net/[/url])
    > To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]
    --
    Ted Huntington
    Programmer Analyst I
    Main Library
    University of California, Irvine
    PO Box 19557
    Irvine, CA 92623-9557

    Phone Bus Off 949 824 8926
    Phone MRC 949 824 1674
    emesg: [email]thunting@uci.edu[/email]
    webpage: [url]http://business.lib.uci.edu/webpages/ted.htm[/url]
    "Stop violence, teach science."


    Ted Huntington Guest

  5. #4

    Default Re: [PHP] fwrite int or float

    I basically solved this problem of writing a 32 bit float in little endian on
    a big endian computer using:
    $num2=pack("f",$num);
    fwrite($fp,$num2[3],1);
    fwrite($fp,$num2[2],1);
    fwrite($fp,$num2[1],1);
    fwrite($fp,$num2[0],1);

    for floating point (I am working on a UNIX [big endian] making a file for i86
    [little endian]).

    The more info, the better, perhaps some body else will search and find this
    if ever the need.


    Ted Huntington wrote:
    > I should have type "signed 32 bit little endian" and little endian float.
    >
    > Ted Huntington wrote:
    >
    > > ok I see to use the "pack" command, but now how do I format to 32 bit
    > > little endian?
    > >
    > > Ted Huntington wrote:
    > >
    > > > Is there some easy way to fwrite a 32 bit int or float?
    > > >
    > > > --
    > > > Ted Huntington
    > > > Programmer Analyst I
    > > > Main Library
    > > > University of California, Irvine
    > > > PO Box 19557
    > > > Irvine, CA 92623-9557
    > > >
    > > > Phone Bus Off 949 824 8926
    > > > Phone MRC 949 824 1674
    > > > emesg: [email]thunting@uci.edu[/email]
    > > > webpage: [url]http://business.lib.uci.edu/webpages/ted.htm[/url]
    > > > "Stop violence, teach science."
    > > >
    > > > --
    > > > PHP General Mailing List ([url]http://www.php.net/[/url])
    > > > To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]
    > >
    > > --
    > > Ted Huntington
    > > Programmer Analyst I
    > > Main Library
    > > University of California, Irvine
    > > PO Box 19557
    > > Irvine, CA 92623-9557
    > >
    > > Phone Bus Off 949 824 8926
    > > Phone MRC 949 824 1674
    > > emesg: [email]thunting@uci.edu[/email]
    > > webpage: [url]http://business.lib.uci.edu/webpages/ted.htm[/url]
    > > "Stop violence, teach science."
    > >
    > > --
    > > PHP General Mailing List ([url]http://www.php.net/[/url])
    > > To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]
    >
    > --
    > Ted Huntington
    > Programmer Analyst I
    > Main Library
    > University of California, Irvine
    > PO Box 19557
    > Irvine, CA 92623-9557
    >
    > Phone Bus Off 949 824 8926
    > Phone MRC 949 824 1674
    > emesg: [email]thunting@uci.edu[/email]
    > webpage: [url]http://business.lib.uci.edu/webpages/ted.htm[/url]
    > "Stop violence, teach science."
    >
    > --
    > PHP General Mailing List ([url]http://www.php.net/[/url])
    > To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]
    --
    Ted Huntington
    Programmer Analyst I
    Main Library
    University of California, Irvine
    PO Box 19557
    Irvine, CA 92623-9557

    Phone Bus Off 949 824 8926
    Phone MRC 949 824 1674
    emesg: [email]thunting@uci.edu[/email]
    webpage: [url]http://business.lib.uci.edu/webpages/ted.htm[/url]
    "Stop violence, teach science."


    Ted Huntington Guest

  6. #5

    Default Re: [PHP] fwrite int or float

    * Thus wrote Ted Huntington (thunting@uci.edu):
    > I basically solved this problem of writing a 32 bit float in little endian on
    > a big endian computer using:
    > $num2=pack("f",$num);
    > fwrite($fp,$num2[3],1);
    > fwrite($fp,$num2[2],1);
    > fwrite($fp,$num2[1],1);
    > fwrite($fp,$num2[0],1);
    >
    > for floating point (I am working on a UNIX [big endian] making a file for i86
    > [little endian]).
    >
    > The more info, the better, perhaps some body else will search and find this
    > if ever the need.
    There was a large discussion on this about two weeks ago, check the
    archives on 'big endian'



    Curt
    --
    "I used to think I was indecisive, but now I'm not so sure."
    Curt Zirzow Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139