PHP 4.0 Bug #6884: problem getting a double variable from binary file
| From: | heinrich at noiseconcept dot de | Date: | Tue, 26 Sep 2000 06:40:06 +0000 |
| Subject: | PHP 4.0 Bug #6884: problem getting a double variable from binary file | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-33661@lists.php.net to get a copy of this message | ||
From: heinrich@noiseconcept.de
Operating system: Win2k/98/Redhat6.1
PHP version: 4.0.2
PHP Bug Type: Variables related
Bug description: problem getting a double variable from binary file
Hi!
Probably this isn't a true bug, bit I couldn't find ANY
one (tried Newsgroups/IRC/Doc's..) who could explain this
to me:
I'm reading a price list from a file in which there are
(beyond other stuff) Product name and price saved.
Extracting the Product name is no problem but the price
is saved as a 8byte-double variable. So I used:
$price=unpack("d",substr($contents,211,8));
But this results in absolutely strange values like
8.3...+E-311 and so on. My file is valid since I've also
programmed this using Borland Delphi. There I use
the command "move" to move the part of the memory where
the file buffer is saved directly to the address of a
double variable. There it works quite fine. So - what's
wrong? (Although I'm KNOW that it's an 8byte double I
tried with any other decoding method from unpack like float,
single and so on... Nothing worked..
Please contact me If you know anything about that, it's
quite important for me :-}
Tnx a lot! - bye!