Well I'm using it to get info from a server and it sends back the binary data (a 4 character/byte string) of a 32 bit float which I'm able to convert into hex. I'll attach a base converter so you can see what I mean.
well I don't know how that program is doing it but you cannot get a hex to have a decimal. it is always rounded up to the next one if over 5 or 7 can't remember.
but you could get creative about php to do what you want. other than that php doesn't have a built in function for this. if you had the code for that little program then maybe you can convert it to php. I don't even know how they are changing the number to be a float
That hex number is the exact data in ram for a 32 bit float. In C++ for example you would just use the memcpy function and copy the int's data into the float variable.
Well a float has to be stored somehow right? Well it get stored in ram as 32 bits of data. It's not stored in two pieces like a number before and after a decimal. Depending on the bits the computer determines if it's negative and what is before and after the decimal.
More info on what I'm doing:
Server responds with the following packet:
(int32) -1
(byte) ASCII 'D' (players response, S2A_PLAYER)
(byte) active client count
for each active client
(byte) client number / index
(string) player name
(int32) client's frag total
(float32) client's total time in-game
I'm trying to get that 32 bit float into an int with php. Easy to do in VB or C++ but I'm having trouble with php.
The float comes from a game server. The game server was made with C++ and sends the data over a winsock connection. The data comes in string form which I'm able to convert to hex but not into float. I haven't tried that file thing and may be worth trying if theres no functions that will do this. Is there a way to write a C++ plugin or module of something for php that will create a function to do this?
sorry I can't read that string, what language is that?
also you mentioned tha tis could be done in C++ so I assumed that you knew C and so you can make a dll in that language or VB, which ever. I have no idea how to make one, I just mentioned it.
That string is the hex data converted into ASCII form. I could code the dll if I knew what exports would have to be used or maybe see a description of the COM function and possible be able to figure it out from there.