Reply to Re: PHP Sockets: Reconstructing Floating Point Numbers

Your name:

Reply:


Posted by Jerry Stuckle on 09/27/07 13:07

DM wrote:
> "Erwin Moller"
> <Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> wrote in
> message news:46fb87ea$0$244$e4fe514c@news.xs4all.nl...
>> DM wrote:
>>> Hi All,
>>>
>>> I'm writing a program that connects to a data stream containing a number
>>> of
>>> different variable types. Ie 4 & 8 byte integers, ASCII characters and 8
>>> byte floats.
>>>
>>> I use fgetc to capture the data in characters then I reconstruct the
>>> variables from these bytes.
>>>
>>> For integers this is easy, just multiply the bytes by orders of 256 to
>>> get
>>> the right offset values. The thing I can't figure out is how to
>>> reconstruct
>>> a double precision floating point number from its 8 component bytes.
>>>
>>> Is there an easy way to do this in PHP? I couldn't find anything useful
>>> through
>>> Google...
>>>
>>> Any pointers would be greatly appreciated.
>>>
>>> -DM
>>>
>> Hi DM,
>>
>> This data stream, where is it coming from?
>> What program is producing it?
>> Also PHP?
>>
>> Regards,
>> Erwin Moller
>
> Hi Erwin, thanks for the reply.
>
> The data stream is coming from a custom Win32 Visual C++ real-time server
> program which pumps out up to 1,000,000 of these multi-type messages per
> day.
>
> I would like to grab and parse this data, then insert it into a postgreSQL
> database under Linux rather than looking for a Windows solution.
>
> I'm looking for a way to get this data into the postgres database so I can
> utillise a whole suite of PHP diagnostic & analysis program I wrote for
> another similar application.
>
> I had a look at the IEEE standard for double precision floats, but it looks
> like I would have to do around 10-15 calculations per message to manually
> restore the value. This would be impractical for the amount of through-put I
> am facing...
>
> -DM
>
>

Personally, if I were looking at this much data, I'd be looking at a
compiled language such as C/C++. If the data is coming in in binary,
just stuff it in the appropriate bytes in a variable and you're done.

Converting floating point variables is not fun, as you have found.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация