PHP - How do I convert a 6byte string storing a 48bit floating point to a number in PHP?
-
AMOS supports a 48-bit floating point format consisting of a 40-bit mantissa, 8-bit exponent, and a signbit. Because a normalized mantissa always starts with a binary one in the high-order bit, this bit is not stored in the floating point number but is always assumed to be present. This allows us to represent the 40-bit mantissa in only 39 bits.
-
Answer:
Try this: $number = unpack('f', $six_byte_string); For more information, see: http://www.php.net/unpack
skett197... at Yahoo! Answers Visit the source
Other answers
You probably need to convert it to an IEEE 64-bit floating point (double) by bit-shifting. I don't know how you do this in PHP - if you discover it isn't possible you can write an external program (e.g. in C) to do the conversion for you. Populate a stream with the bits of the 6-byte string, inserting the required bits to pad it to a 64-bit float. Then read in the stream to a double as if you were reading it from a new file.
Marc
sorry
taketwo
Related Q & A:
- How do I convert a PDF file to PDF/A in Delphi?Best solution by softwarerecs.stackexchange.com
- How do I convert a bitmap to vector?Best solution by Super User
- How can I use a button to retrieve a phone 'number' from contacts?Best solution by Stack Overflow
- How can I burn a .rmvb file onto a DVD for viewing on a regular DVD player?Best solution by Yahoo! Answers
- How can I convert a video to mp3 format?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.