mirror of
https://github.com/schibo/1964js.git
synced 2025-04-02 10:52:54 -04:00
git-svn-id: http://1964js.googlecode.com/svn/trunk@178 0378edba-076e-5dc0-2bb2-d87a714dcd81
24 lines
488 B
Dart
24 lines
488 B
Dart
library stringutils;
|
|
|
|
class StringUtils {
|
|
|
|
/**
|
|
* Returns a hexadecimal representaion of an integer.
|
|
* Convenient for printing in log messages.
|
|
*/
|
|
static String dec2hex(int u) {
|
|
int d = 0;
|
|
String hD = "0123456789ABCDEF";
|
|
d = u;
|
|
String h = hD.substring((d & 15), (d & 15) + 1);
|
|
for (;;) {
|
|
d >>= 4;
|
|
d &= 0x0fffffff;
|
|
h = hD.substring((d & 15), (d & 15) + 1).concat(h);
|
|
if (!(d > 15)) {
|
|
break;
|
|
}
|
|
}
|
|
return h;
|
|
}
|
|
}
|