Hi!
What precision do you need?
Describe your project.
The three conversions below (44340, 13107 and 13)
are performed using the solution of the user Ingvar.
(See his previous post).
From the PicBasic Pro manual:
PicBasic Pro multiply (*) function
operates as a 16-bit x 16-bit multiply
yielding a 32-bit internal result.
4.17.1. Multiplication
PBP performs unsigned 16-bit x 16-bit multiplication.
The '*' operator returns the lower 16 bits of
the 32-bit internal result. This is the typical
multiplication found in most programming languages.
The '**' operator returns the upper 16 bits of
the 32-bit internal result. These two operators
can be used in conjunction to perform 16-bit x 16-bit
multiplication that produces 32-bit results.
========================================
(See original post of the user Walter/RFsolution)
With the Windows calculator:
65535/360 = 182.04166666666666666666666666667
========================================
44340 conversion
44340 * 360 = 15962400
15962400 = 00000000111100111001000100100000 (32-bit internal result)
-----------0000000011110011-1001000100100000
-------------(upper 16 bits )-----(lower 16 bits )
Upper 16 bits of the 32-bit internal result = 0000000011110011 = 243 decimal
Lower 16 bits of the 32-bit internal result = 1001000100100000 = 37152 decimal
37152 * 1000 = 37152000
37152000 = 00000010001101101110010100000000 (32-bit internal result)
-----------0000001000110110-1110010100000000
-------------(upper 16 bits )-----(lower 16 bits )
Upper 16 bits of the 32-bit internal result = 0000001000110110 = 566 decimal
Lower 16 bits of the 32-bit internal result = 1110010100000000 = 58624 decimal
Display = 243.566
With the Windows calculator:
44340 / 182.04166666666666666666666666667
= 243.57061112382696269169146257725
========================================
13107 conversion (65535/5 = 13107 ---- 360 / 5 = 72 degrees)
44340 * 360 = 4718520
4718520 = 10001111111111110111000
1000111-1111111110111000
(up.part)---(lo. part)
Upper part 1000111 = 71 decimal
Lower part 1111111110111000 = 65464 decimal
65464 * 1000 = 65464000
65464000 = 11111001101110011011000000
1111100110-1110011011000000
(up.part)---(lo. part)
Upper part = 1111100110 = 998 decimal
Lower part = 1110011011000000 = 59072 decimal
Display = 71.998
With the Windows calculator:
13107 / 182.04166666666666666666666666667
= 72
========================================
13 conversion
13 * 360 = 4680
4680 = 0-0001001001001000
-------(up.part)---(lo. part)
Upper part 0 = 0 decimal
Lower part 1001001001000 = 4680 decimal
4680 * 1000 = 4680000
4680000 = 10001110110100101000000
1000111-0110100101000000
(up.part)---(lo. part)
Upper part = 1000111 = 71 decimal
Lower part = 1110011011000000 = 59072 decimal
Display = 0.071
With the Windows calculator:
13 / 182.04166666666666666666666666667
= 0.071412222476539253833829251544976
========================================
* * * * * * * *
About precision
Example with earth's longitude:
A degree of longitude at the equator is 111.2 kilometers
a minute is 1853 meters and a second is 30.9 meters.
* * * *
Convert degrees to decimal degrees:
Example 09°59'58" (9 degrees, 59 minutes, 58 seconds).
= Decimal degrees 9.9994
Example 09°59'57" (9 degrees, 59 minutes, 57 seconds).
= Decimal degrees 9.9991
Example 09°59'56" (9 degrees, 59 minutes, 56 seconds).
= Decimal degrees 9.9988
* * * *
Convert decimal degrees to degrees:
9.999 > 09°59'56"
9.998 > 09°59'52"
9.997 > 09°59'49"
* * * *
Above conversions done with:
http://www.beg.utexas.edu/GIS/tools/DMS_DD.htm
http://www.beg.utexas.edu/GIS/tools/dd_dms.htm
Best regards,
Luciano
Bookmarks