|
-
Apr 7th, 2000, 02:58 AM
#1
Thread Starter
Frenzied Member
Do to another Query, I started trying to determine the algorithm for conversion to Double, and the appearance of doubles in memory.
Not wanting to reinvent the wheel, I checked a few Web Sites, but was unable to find a precise description of double variables (The IEEE site did not have a readily available description, even though that organization is responsible for the specifications).
I developed a simple VB application which accepted some input data, converted to Doubles, singles, and Longs (if possible), and wrote to a file. I then investigated the file using a Hex Editor (The one supplied with Ztree).
Here are some results. Do you believe them? If not, can you provide the Doubles and singles corresponding to my Decimal values? Better yet, do you know the algorithm which describes conversion of decimal data to double/single? I think 9 or 10 bits of a double make an exponent and the rest comprise a binary value.
Decimal 450,123 (Hex 6D,E4B) results in Long: 4BDE 0600
Corresponding Double: 0000 0000 2C79 1B41
Corresponding Single: 60C9 DB48
Integers and Longs arrange the digits differently than a human being would, but the algorithm is fairly obvious. It boggled my mind when I compared doubles with correspondiing Singles, and found no obvious correlation. This makes me wonder about possible bugs in my application and/or makes me suspect my Hex Editor.
Decimal .0001 (Hex .0006 8DB8 BAC7 1CA, I think).
Corresponding double: 2D43 1CEB E236 1A3F
Corresponding Single: 17B7 D138
If interested, I have other data ([email protected]), including some powers of two, integers 1-9, fractional powers of two (EG: 1/2, 1/4, 1/8), and other values. These examples provide some clues, but I have not yet figured out what is happening.
I expected to see something obvious, and am wondering if my VB application or the Hex Editor have errors.
Thanx for help --- Gouverneur Cadwallader (Dinosaur from prehistoric Mainfame era)
-
Apr 7th, 2000, 03:11 AM
#2
Member
Are you using the CDbl() (converts to a double), CSng() (converts to a single), etc. functions that convert one data type to another?
LauRa
LauRa
"Work like you don't need the money...Love like you've never been hurt...Dance like nobody is watching..."
-
Apr 7th, 2000, 03:36 AM
#3
Thread Starter
Frenzied Member
Yes, I used CDbl & CSng
Answer to question posed in first reply.
I used standard VB conversion functions (CDbl, CSng, Clng), a common dialog box, standard VB Open (for binary mode), and standard VB Put.
If my results did not confuse me, I would be certain that my VB application and subsequent analysis was correct.
-
Apr 7th, 2000, 03:42 AM
#4
I just posted this in the previous thread. Here is a link to IEEE specifications for single and double floating points.
http://www.research.microsoft.com/~h...ieeefloat.html
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|