开发者

Convert hexadecimal notation into latitudinal hours and minutes

开发者 https://www.devze.com 2022-12-28 17:45 出处:网络
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:

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号