mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Use std::reverse for binary digits
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "asm/format.hpp"
|
#include "asm/format.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
@@ -190,17 +191,10 @@ void FormatSpec::printNumber(char *buf, size_t bufLen, uint32_t value) {
|
|||||||
value >>= 1;
|
value >>= 1;
|
||||||
} while (value);
|
} while (value);
|
||||||
|
|
||||||
*ptr = '\0';
|
|
||||||
|
|
||||||
// Reverse the digits
|
// Reverse the digits
|
||||||
size_t valueLen = ptr - valueBuf;
|
std::reverse(valueBuf, ptr);
|
||||||
|
|
||||||
for (size_t i = 0, j = valueLen - 1; i < j; i++, j--) {
|
*ptr = '\0';
|
||||||
char c = valueBuf[i];
|
|
||||||
|
|
||||||
valueBuf[i] = valueBuf[j];
|
|
||||||
valueBuf[j] = c;
|
|
||||||
}
|
|
||||||
} else if (type == 'f') {
|
} else if (type == 'f') {
|
||||||
// Special case for fixed-point
|
// Special case for fixed-point
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user