TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: FELIX on February 05, 2019, 07:31:24 PM
-
123 82 149 98 55 49 27 65 --> 445517.8462
2 69 211 172 177 213 89 65 --> 6771539.4103
1 2 3 4 5 6 7 8
how did this conversion? No need to program just explain briefly.
-
I couldn't leave this at I don't know. So I worked it out
Following on from http://www.theswamp.org/index.php?topic=54889.0 (http://www.theswamp.org/index.php?topic=54889.0)
(123 82 149 98 55 49 27 65) to 445517.846238412
Double precision floating point 64 bit number to decimal
reverse the list
convert each decimal to binary
strcat the lot together
you get
01000001 00011011 00110001 00110111
01100010 10001100 01010010 10000001
The first digit is the sign, 0 for positive 1 for negative
The next 11 sigits is the exponent 10000010001 convert this to decimal which is 1041 then - 1023 to get the exponent = 18
The last 52 digits is the mantissa 1011001100010011011101100010100011000101001010000001 you must append this with a "1." (including the decimal point) at the front so that it is actually 1.1011001100010011011101100010100011000101001010000001
convert this is decimal so that it is 1.69951570983280952909 then times it by 2 to the power of the exponent 2^18 = 262144
1.66... x 262144 = 445517.846238412
Finally got there
Cheers, Rod
-
Nice work Rod, was only reading about this today when it popped up in a news feed http://fabiensanglard.net/floating_point_visually_explained/index.php
which also lead to another good explanation from the comments for those interested - https://www.youtube.com/watch?v=pQs_wx8eoQ8
When I read the OP I was a bit unsure until you pointed out the first digit was the sign bit :)
-
Excellent ROD, now it's easy to convert the coordinates that are in binary.
For more than 40 years I have not worked with binary numbers but it's like cycling, we lose practice but not balance.
-
For more than 40 years I have not worked with binary numbers...
Then how old are you?
40 years ago I was a kid 2 years old...
-
For more than 40 years I have not worked with binary numbers...
Then how old are you?
40 years ago I was a kid 2 years old...
My age is: 00111101
-
You're welcome. I didn't even remember that I was taught this once. It was bugging my though and I couldn't resist working on it.
Excellent ROD, now it's easy to convert the coordinates that are in binary.
For more than 40 years I have not worked with binary numbers but it's like cycling, we lose practice but not balance.