mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-02 22:32:08 +00:00
Add new function utohexstr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2140 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b55679d427
commit
35c15b4bfe
@ -11,6 +11,24 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
static inline std::string utohexstr(uint64_t X) {
|
||||||
|
char Buffer[40];
|
||||||
|
char *BufPtr = Buffer+39;
|
||||||
|
|
||||||
|
*BufPtr = 0; // Null terminate buffer...
|
||||||
|
if (X == 0) *--BufPtr = '0'; // Handle special case...
|
||||||
|
|
||||||
|
while (X) {
|
||||||
|
unsigned Mod = X & 15;
|
||||||
|
if (Mod < 10)
|
||||||
|
*--BufPtr = '0' + Mod;
|
||||||
|
else
|
||||||
|
*--BufPtr = 'A' + Mod-10;
|
||||||
|
X >>= 4;
|
||||||
|
}
|
||||||
|
return std::string(BufPtr);
|
||||||
|
}
|
||||||
|
|
||||||
static inline std::string utostr(uint64_t X, bool isNeg = false) {
|
static inline std::string utostr(uint64_t X, bool isNeg = false) {
|
||||||
char Buffer[40];
|
char Buffer[40];
|
||||||
char *BufPtr = Buffer+39;
|
char *BufPtr = Buffer+39;
|
||||||
|
@ -11,6 +11,24 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
static inline std::string utohexstr(uint64_t X) {
|
||||||
|
char Buffer[40];
|
||||||
|
char *BufPtr = Buffer+39;
|
||||||
|
|
||||||
|
*BufPtr = 0; // Null terminate buffer...
|
||||||
|
if (X == 0) *--BufPtr = '0'; // Handle special case...
|
||||||
|
|
||||||
|
while (X) {
|
||||||
|
unsigned Mod = X & 15;
|
||||||
|
if (Mod < 10)
|
||||||
|
*--BufPtr = '0' + Mod;
|
||||||
|
else
|
||||||
|
*--BufPtr = 'A' + Mod-10;
|
||||||
|
X >>= 4;
|
||||||
|
}
|
||||||
|
return std::string(BufPtr);
|
||||||
|
}
|
||||||
|
|
||||||
static inline std::string utostr(uint64_t X, bool isNeg = false) {
|
static inline std::string utostr(uint64_t X, bool isNeg = false) {
|
||||||
char Buffer[40];
|
char Buffer[40];
|
||||||
char *BufPtr = Buffer+39;
|
char *BufPtr = Buffer+39;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user