473,651 Members | 3,068 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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....

Oct 13 '05 #1
1 4901
no****@gmail.co m wrote:
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


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

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

--
E. Dronkert
Oct 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
3009
by: Pascal | last post by:
Hello, I've a binary file with data in it. This file come from an old ms dos application (multilog ~ 1980). In this application, a field is declared as a 'decimal' (999 999 999.99). I put 0.00 in the field and save the record to the file. When I look in the binary file (with python or an hex editor), the field is stored on 8 bytes: 00-00-00-00-00-00-7F-00. I try unpack from struct module but the result isn't good.
1
5580
by: Mahesh | last post by:
Dear friends, In the following code, I can't read the float value from file(temp.txt). Run-time error is coming. I am using Visual C++. #include<stdio.h> #include<math.h> #include<string.h> #include<stdlib.h> int main() {
0
4820
by: sangui | last post by:
Helllo. this is biginner programmer. Would u check the file that I programed on c#(winform)? I tryed to make the program reading the binary file by C# programming but I failed. If u have more free time, would u program for ur skill up and me ^^; below contens is programed by unix c.
1
1248
by: Anderson | last post by:
Dear all, Could anyone tell me how to convert binary data in buffer to string format,thanks in advance! Anderson
6
9221
by: Java1963 | last post by:
Need help with writting an application that prompt for and read a double value representing a monetary amount. -------------------------------------------------------------------------------- Hello all, I am new to this Java stuff and, I need help in writting an application will prompt for and read a double value representing a monetary amount.Then determine the fewest numbers of each bill and coin needed to represent that amount,...
6
7364
by: ericunfuk | last post by:
Hi ALL, I want to read a binary file(it's pic.tif file, I guess it's binary file?), then write it to a new file), I have several questions about this process: When I use fread() to read a chunk of the file into a buffer, when it encounters the end of the file, will the EOF indicator be put into the buffer automatically just as an ordinary byte of the file, or do I have to do it manually?
6
342
by: zl2k | last post by:
hi, there I have a appendable binary file of complex data structure named data.bin created by myself. It is written in the following format: number of Data, Data array Suppose I have following data.bin (3 Data appended to 2 Data): 2, data0, data1, 3, data0, data1, data2
3
2341
by: Jim Cousins | last post by:
I succeed in extracting all of the header information, and then only a portion of the data. The data section is 123,410 doubles, but after retrieving 62 of the numbers, I can not go further, struct.unpack indicates that the string argument is the wrong length. I set up a loop to get the numbers one at a time, and it stops at the same place. The file is not corrupt, and will open in the original software. Does anyone have suggestions for figuring...
0
8361
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8807
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8466
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8584
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7299
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5615
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1912
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1588
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.