internal number representation
|
10-05-2016, 03:42 PM
Post: #2
|
|||
|
|||
RE: internal number representation
You can directly look at the binary structure of any THPObj (as we call them) by storing the item using AFiles. AFilesB will allow direct return of the item as byte arrays. Another post from cyrille (coincidentally near the same time as your question) talks a bit about the header on the front of the objects.
Quote:Actually, what you are doing when you do: AFiles("num"):=0 followed by AFilesB("num",0,16) returns the full byte representation of the file. In your case, skip the first 8 and look at the last 8 bytes. That is the real number encoding in BCD. I'm also including some comments from a header file which should be helpful. Code: * see the HP_Real structure to see how reals are stored (sign, exponent, mantissa) Note that we really only use the e499 version from the end user perspective. Other longer use is only internal and even then we don't use the extended exponent capacity at all. Also, when saving to disk the reals get packed to save space. Hence, the return from AFiles only takes 8 bytes for a single real. "Packing" basically means that there is only space for the 12digit BCD, 3 byte exponent, and 1 byte sign vs the 15 digit bcd, 4 byte exponent, and 1 byte sign of the "unpacked" real. If you're interested, the code to do the packing looks like this: Code: PackedHP_Real fPack(HP_Real const *a) Heres is more comments about the unpacked HP_Real. Code: /// A HP_Real is a group of 3 elements. A Sign (which is also can carry information on Really, the primary difference between the HP48 series encoding of reals and the newer encoding is that instead of encoding the exponent as BCD, that is encoded as a plain integer value while the mantissa is still kept in BCD. Perhaps someone can link to or find a good reference where the 48 real number encoding is explained??? From this explanation, you can probably pretty easily figure out how a complex is encoded (2 paired reals with a different header), a matrix (size info, followed by reals), a complex matrix, etc. TW Although I work for HP, the views and opinions I post here are my own. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
internal number representation - retoa - 10-05-2016, 06:25 AM
RE: internal number representation - Tim Wessman - 10-05-2016 03:42 PM
RE: internal number representation - retoa - 10-05-2016, 09:27 PM
RE: internal number representation - David Hayden - 10-07-2016, 01:05 AM
RE: internal number representation - retoa - 10-07-2016, 07:30 AM
RE: internal number representation - jte - 10-08-2016, 08:37 PM
RE: internal number representation - cyrille de brébisson - 10-10-2016, 10:05 AM
|
User(s) browsing this thread: 1 Guest(s)