Re: fwrite int or float
| From: | Ted Huntington | Date: | Thu, 24 Jul 2003 23:39:33 +0000 |
| Subject: | Re: fwrite int or float | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-156769@lists.php.net to get a copy of this message | ||
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: thunting@uci.edu
> > > webpage:
> > > http://business.lib.uci.edu/webpages/ted.htm
> > > "Stop violence, teach science."
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> > --
> > 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: thunting@uci.edu
> > webpage: http://business.lib.uci.edu/webpages/ted.htm
> > "Stop violence, teach science."
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> 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: thunting@uci.edu
> webpage: http://business.lib.uci.edu/webpages/ted.htm
> "Stop violence, teach science."
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--
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: thunting@uci.edu
webpage: http://business.lib.uci.edu/webpages/ted.htm
"Stop violence, teach science."