Given:
0x12E7
represents 48°39'0x3026
represents 123°26'
What is the most efficient way to convert the representation of those latitudes into two variables:
开发者_Go百科- hours
- minutes
Where the first example would be:
- hours = 48
- minutes = 39
And the second example:
- hours = 123
- minutes = 26
Edit
Latitude is an int
.
int l = 0x12E7;
int h = l / 100;
int m = l % 100;
System.out.printf("%d°%d'", h, m); // 48°39'
If you have a String
value:
int i = Integer.parseInt("12E7", 16);
int hours = i / 100;
int minutes = i % 100;
Or you can use the 0x...
format directly:
int i = 0x12E7;
int hours = i / 100;
int minutes = i % 100;
hours = 0x12E7 / 100;
minutes = 0x12E7 % 100;
精彩评论