aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormax99x <max99x@gmail.com>2011-06-28 13:24:05 +0300
committermax99x <max99x@gmail.com>2011-06-28 13:34:23 +0300
commit126df9fa21f59c41456208879165805b908699d5 (patch)
tree0837408c8e9510aea70c619e80d01116b6e6e5d8
parent0ea0b71b3464198288a27ad21072e32166fcc2de (diff)
Added proper argument size support to _formatString/printf.
-rw-r--r--src/library.js118
-rw-r--r--tests/printf/output.txt279
-rw-r--r--tests/printf/test.c279
3 files changed, 643 insertions, 33 deletions
diff --git a/src/library.js b/src/library.js
index 81ab6094..284f093d 100644
--- a/src/library.js
+++ b/src/library.js
@@ -65,9 +65,6 @@ var Library = {
_formatString__deps: ['$STDIO', 'isdigit'],
_formatString: function() {
- function isFloatArg(type) {
- return String.fromCharCode(type).toLowerCase() in Runtime.set('f', 'e', 'g');
- }
var cStyle = false;
var textIndex = arguments[0];
var argIndex = 1;
@@ -78,20 +75,20 @@ var Library = {
} else {
var _arguments = arguments;
}
- function getNextArg(type) {
+ function getNextArg(isFloat, size) {
var ret;
if (!cStyle) {
ret = _arguments[argIndex];
argIndex++;
} else {
- if (isFloatArg(type)) {
+ if (isFloat) {
ret = {{{ makeGetValue(0, 'argIndex', 'double') }}};
} else {
ret = {{{ makeGetValue(0, 'argIndex', 'i32') }}};
}
- argIndex += {{{ QUANTUM_SIZE === 1 ? 1 : "type === 'l'.charCodeAt(0) ? 8 : 4" }}};
+ argIndex += {{{ QUANTUM_SIZE === 1 ? 1 : 'Math.max(4, size || 0)' }}};
}
- return ret;
+ return +ret; // +: boolean=>int
}
var ret = [];
@@ -135,7 +132,7 @@ var Library = {
// Handle width.
var width = 0;
if (next == '*'.charCodeAt(0)) {
- width = getNextArg('i');
+ width = getNextArg();
textIndex++;
next = {{{ makeGetValue(0, 'textIndex+1', 'i8') }}};
} else {
@@ -154,7 +151,7 @@ var Library = {
textIndex++;
next = {{{ makeGetValue(0, 'textIndex+1', 'i8') }}};
if (next == '*'.charCodeAt(0)) {
- precision = getNextArg('i');
+ precision = getNextArg();
textIndex++;
} else {
while(1) {
@@ -169,40 +166,94 @@ var Library = {
var precision = 6; // Standard default.
}
- // Handle (ignore) integer sizes.
- // TODO: Properly handle the sizes, for C style args.
- if (next == 'l'.charCodeAt(0) && {{{ makeGetValue(0, 'textIndex+2', 'i8') }}} == 'l'.charCodeAt(0) ||
- next == 'h'.charCodeAt(0) && {{{ makeGetValue(0, 'textIndex+2', 'i8') }}} == 'h'.charCodeAt(0)) {
- textIndex += 2;
- next = {{{ makeGetValue(0, 'textIndex+1', 'i8') }}};
- } else if (next == 'l'.charCodeAt(0) || next == 'L'.charCodeAt(0) ||
- next == 'h'.charCodeAt(0) || next == 'z'.charCodeAt(0) ||
- next == 'j'.charCodeAt(0) || next == 't'.charCodeAt(0) ||
- next == 'I'.charCodeAt(0) || next == 'q'.charCodeAt(0)) {
- textIndex++;
- next = {{{ makeGetValue(0, 'textIndex+1', 'i8') }}};
+ // Handle integer sizes. WARNING: These assume a 32-bit architecture!
+ var argSize;
+ switch (String.fromCharCode(next)) {
+ case 'h':
+ var nextNext = {{{ makeGetValue(0, 'textIndex+2', 'i8') }}};
+ if (nextNext == 'h'.charCodeAt(0)) {
+ textIndex++;
+ argSize = 1; // char
+ } else {
+ argSize = 2; // short
+ }
+ break;
+ case 'l':
+ var nextNext = {{{ makeGetValue(0, 'textIndex+2', 'i8') }}};
+ if (nextNext == 'l'.charCodeAt(0)) {
+ textIndex++;
+ argSize = 8; // long long
+ } else {
+ argSize = 4; // long
+ }
+ break;
+ case 'L': // long long
+ case 'q': // int64_t
+ case 'j': // intmax_t
+ argSize = 8;
+ break;
+ case 'z': // size_t
+ case 't': // ptrdiff_t
+ case 'I': // signed ptrdiff_t or unsigned size_t
+ argSize = 4;
+ break;
+ default:
+ argSize = undefined;
}
+ if (argSize !== undefined) textIndex++;
+ next = {{{ makeGetValue(0, 'textIndex+1', 'i8') }}};
// Handle type specifier.
if (['d', 'i', 'u', 'o', 'x', 'X', 'p'].indexOf(String.fromCharCode(next)) != -1) {
// Integer.
- var currArg = +getNextArg(next); // +: boolean=>int
+ var signed = next == 'd'.charCodeAt(0) || next == 'i'.charCodeAt(0);
+ var currArg = getNextArg(false, argSize);
+ // Truncate to requested size.
+ argSize = argSize || 4;
+ var limit = undefined;
+ if (argSize == 4) {
+ limit = 0xFFFFFFFF;
+ } else if (argSize == 2) {
+ limit = 0xFFFF;
+ } else if (argSize == 1) {
+ limit = 0xFF;
+ }
+ if (limit !== undefined) {
+ currArg = currArg & limit;
+ if (!signed && currArg < 0 || signed && currArg > (limit - 1) / 2) {
+ currArg = ~(limit - currArg);
+ }
+ }
+ // Format the number.
var currAbsArg = Math.abs(currArg);
var argText;
var prefix = '';
if (next == 'd'.charCodeAt(0) || next == 'i'.charCodeAt(0)) {
argText = currAbsArg.toString(10);
} else if (next == 'u'.charCodeAt(0)) {
- argText = unSign(currArg, 32).toString(10);
+ argText = unSign(currArg, 8 * argSize).toString(10);
currArg = Math.abs(currArg);
} else if (next == 'o'.charCodeAt(0)) {
argText = (flagAlternative ? '0' : '') + currAbsArg.toString(8);
- } else if (next == 'x'.charCodeAt(0)) {
+ } else if (next == 'x'.charCodeAt(0) || next == 'X'.charCodeAt(0)) {
prefix = flagAlternative ? '0x' : '';
- argText = currAbsArg.toString(16);
- } else if (next == 'X'.charCodeAt(0)) {
- prefix = flagAlternative ? '0X' : '';
- argText = currAbsArg.toString(16).toUpperCase();
+ if (currArg < 0) {
+ // Represent negative numbers in hex as 2's complement.
+ currArg = -currArg;
+ argText = (currAbsArg - 1).toString(16);
+ var buffer = [];
+ for (var i = 0; i < argText.length; i++) {
+ buffer.push((0xF - parseInt(argText[i], 16)).toString(16));
+ }
+ argText = buffer.join('');
+ while (argText.length < argSize * 2) argText = 'f' + argText;
+ } else {
+ argText = currAbsArg.toString(16);
+ }
+ if (next == 'X'.charCodeAt(0)) {
+ prefix = prefix.toUpperCase();
+ argText = argText.toUpperCase();
+ }
} else if (next == 'p'.charCodeAt(0)) {
prefix = '0x';
argText = currAbsArg.toString(16);
@@ -233,13 +284,14 @@ var Library = {
}
}
+ // Insert the result into the buffer.
argText = prefix + argText;
argText.split('').forEach(function(chr) {
ret.push(chr.charCodeAt(0));
});
} else if (['f', 'F', 'e', 'E', 'g', 'G'].indexOf(String.fromCharCode(next)) != -1) {
// Float.
- var currArg = +getNextArg(next); // +: boolean=>int
+ var currArg = getNextArg(true, argSize);
var argText;
if (isNaN(currArg)) {
@@ -323,7 +375,7 @@ var Library = {
});
} else if (next == 's'.charCodeAt(0)) {
// String.
- var copiedString = String_copy(getNextArg(next));
+ var copiedString = String_copy(getNextArg());
if (precisionSet && copiedString.length > precision) {
copiedString = copiedString.slice(0, precision);
}
@@ -340,14 +392,14 @@ var Library = {
}
} else if (next == 'c'.charCodeAt(0)) {
// Character.
- if (flagLeftAlign) ret = ret.concat(getNextArg(next));
+ if (flagLeftAlign) ret.push(getNextArg());
while (--width > 0) {
ret.push(' '.charCodeAt(0));
}
- if (!flagLeftAlign) ret = ret.concat(getNextArg(next));
+ if (!flagLeftAlign) ret.push(getNextArg());
} else if (next == 'n'.charCodeAt(0)) {
// Write the length written so far to the next parameter.
- {{{ makeSetValue('getNextArg("d")', '0', 'ret.length', 'i32') }}}
+ {{{ makeSetValue('getNextArg()', '0', 'ret.length', 'i32') }}}
} else if (next == '%'.charCodeAt(0)) {
// Literal percent sign.
ret.push(curr);
diff --git a/tests/printf/output.txt b/tests/printf/output.txt
index 7ea7b01c..80b4db80 100644
--- a/tests/printf/output.txt
+++ b/tests/printf/output.txt
@@ -8017,3 +8017,282 @@ in%3.5valid
%-5p : 0x4f318
%-10p : 0x4f318
%-30p : 0x4f318
+
+de
+bcde
+789abcde
+789abcde
+123456789abcde
+123456789abcde
+
+de
+bcde
+789abcde
+789abcde
+123456789abcde
+123456789abcde
+
+de
+bcde
+789abcde
+789abcde
+123456789abcde
+123456789abcde
+
+789abcde
+123456789abcde
+789abcde
+123456789abcde
+789abcde
+
+-34
+-17186
+2023406814
+2023406814
+5124095576030430
+5124095576030430
+
+-34
+-17186
+2023406814
+2023406814
+5124095576030430
+5124095576030430
+
+-34
+-17186
+2023406814
+2023406814
+5124095576030430
+5124095576030430
+
+2023406814
+5124095576030430
+2023406814
+5124095576030430
+2023406814
+
+222
+48350
+2023406814
+2023406814
+5124095576030430
+5124095576030430
+
+222
+48350
+2023406814
+2023406814
+5124095576030430
+5124095576030430
+
+222
+48350
+2023406814
+2023406814
+5124095576030430
+5124095576030430
+
+2023406814
+5124095576030430
+2023406814
+5124095576030430
+2023406814
+
+22
+4322
+87654322
+87654322
+ffedcba987654322
+ffedcba987654322
+
+22
+4322
+87654322
+87654322
+ffedcba987654322
+ffedcba987654322
+
+22
+4322
+87654322
+87654322
+ffedcba987654322
+ffedcba987654322
+
+87654322
+ffedcba987654322
+87654322
+ffedcba987654322
+87654322
+
+34
+17186
+-2023406814
+-2023406814
+-5124095576030430
+-5124095576030430
+
+34
+17186
+-2023406814
+-2023406814
+-5124095576030430
+-5124095576030430
+
+34
+17186
+-2023406814
+-2023406814
+-5124095576030430
+-5124095576030430
+
+-2023406814
+-5124095576030430
+-2023406814
+-5124095576030430
+-2023406814
+
+34
+17186
+2271560482
+2271560482
+18441619978133520000
+18441619978133520000
+
+34
+17186
+2271560482
+2271560482
+18441619978133520000
+18441619978133520000
+
+34
+17186
+2271560482
+2271560482
+18441619978133520000
+18441619978133520000
+
+2271560482
+18441619978133520000
+2271560482
+18441619978133520000
+2271560482
+
+1234567.890123
+1234567.890123
+1234567.890123
+1234567.890123
+
+-1234567.890123
+-1234567.890123
+-1234567.890123
+-1234567.890123
+
+1234567.875000
+1234567.875000
+1234567.875000
+1234567.875000
+
+-1234567.875000
+-1234567.875000
+-1234567.875000
+-1234567.875000
+
+0
+0
+0
+0
+0
+0
+0
+0
+
+1
+1
+1
+1
+1
+1
+1
+1
+
+255
+65535
+4294967295
+18446744073709552000
+ff
+ffff
+ffffffff
+ffffffffffffffff
+
+126
+32766
+2147483646
+140737488355326
+7e
+7ffe
+7ffffffe
+7ffffffffffe
+
+127
+32767
+2147483647
+140737488355327
+7f
+7fff
+7fffffff
+7fffffffffff
+
+128
+32768
+134217728
+549755813888
+80
+8000
+8000000
+8000000000
+
+255
+65535
+4294967295
+281474976710655
+ff
+ffff
+ffffffff
+
+130
+32770
+2147483650
+18446603336221196000
+82
+8002
+80000002
+ffff800000000002
+
+129
+32769
+2147483649
+18446603336221196000
+81
+8001
+80000001
+ffff800000000001
+
+128
+32768
+4160749568
+18446743523953738000
+80
+8000
+f8000000
+ffffff8000000000
+
+1
+1
+1
+18446462598732840000
+1
+1
+1
diff --git a/tests/printf/test.c b/tests/printf/test.c
index 68779e51..b0d83b45 100644
--- a/tests/printf/test.c
+++ b/tests/printf/test.c
@@ -8022,5 +8022,284 @@ int main() {
printf("%-15s: %-5p\n", "%-5p", (void*)324376);
printf("%-15s: %-10p\n", "%-10p", (void*)324376);
printf("%-15s: %-30p\n", "%-30p", (void*)324376);
+ printf("\n");
+ printf("%hhx\n", 0x0123456789ABCDE);
+ printf("%hx\n", 0x0123456789ABCDE);
+ printf("%x\n", 0x0123456789ABCDE);
+ printf("%lx\n", 0x0123456789ABCDE);
+ printf("%llx\n", 0x0123456789ABCDE);
+ printf("%Lx\n", 0x0123456789ABCDE);
+ printf("\n");
+ printf("%hhx\n", 0x0123456789ABCDEl);
+ printf("%hx\n", 0x0123456789ABCDEl);
+ printf("%x\n", 0x0123456789ABCDEl);
+ printf("%lx\n", 0x0123456789ABCDEl);
+ printf("%llx\n", 0x0123456789ABCDEl);
+ printf("%Lx\n", 0x0123456789ABCDEl);
+ printf("\n");
+ printf("%hhx\n", 0x0123456789ABCDEll);
+ printf("%hx\n", 0x0123456789ABCDEll);
+ printf("%x\n", 0x0123456789ABCDEll);
+ printf("%lx\n", 0x0123456789ABCDEll);
+ printf("%llx\n", 0x0123456789ABCDEll);
+ printf("%Lx\n", 0x0123456789ABCDEll);
+ printf("\n");
+ printf("%zx\n", 0x0123456789ABCDEll);
+ printf("%jx\n", 0x0123456789ABCDEll);
+ printf("%tx\n", 0x0123456789ABCDEll);
+ printf("%qx\n", 0x0123456789ABCDEll);
+ printf("%Ix\n", 0x0123456789ABCDEll);
+ printf("\n");
+ printf("%hhd\n", 0x0123456789ABCDE);
+ printf("%hd\n", 0x0123456789ABCDE);
+ printf("%d\n", 0x0123456789ABCDE);
+ printf("%ld\n", 0x0123456789ABCDE);
+ printf("%lld\n", 0x0123456789ABCDE);
+ printf("%Ld\n", 0x0123456789ABCDE);
+ printf("\n");
+ printf("%hhd\n", 0x0123456789ABCDEl);
+ printf("%hd\n", 0x0123456789ABCDEl);
+ printf("%d\n", 0x0123456789ABCDEl);
+ printf("%ld\n", 0x0123456789ABCDEl);
+ printf("%lld\n", 0x0123456789ABCDEl);
+ printf("%Ld\n", 0x0123456789ABCDEl);
+ printf("\n");
+ printf("%hhd\n", 0x0123456789ABCDEll);
+ printf("%hd\n", 0x0123456789ABCDEll);
+ printf("%d\n", 0x0123456789ABCDEll);
+ printf("%ld\n", 0x0123456789ABCDEll);
+ printf("%lld\n", 0x0123456789ABCDEll);
+ printf("%Ld\n", 0x0123456789ABCDEll);
+ printf("\n");
+ printf("%zd\n", 0x0123456789ABCDEll);
+ printf("%jd\n", 0x0123456789ABCDEll);
+ printf("%td\n", 0x0123456789ABCDEll);
+ printf("%qd\n", 0x0123456789ABCDEll);
+ printf("%Id\n", 0x0123456789ABCDEll);
+ printf("\n");
+ printf("%hhu\n", 0x0123456789ABCDE);
+ printf("%hu\n", 0x0123456789ABCDE);
+ printf("%u\n", 0x0123456789ABCDE);
+ printf("%lu\n", 0x0123456789ABCDE);
+ printf("%llu\n", 0x0123456789ABCDE);
+ printf("%Lu\n", 0x0123456789ABCDE);
+ printf("\n");
+ printf("%hhu\n", 0x0123456789ABCDEl);
+ printf("%hu\n", 0x0123456789ABCDEl);
+ printf("%u\n", 0x0123456789ABCDEl);
+ printf("%lu\n", 0x0123456789ABCDEl);
+ printf("%llu\n", 0x0123456789ABCDEl);
+ printf("%Lu\n", 0x0123456789ABCDEl);
+ printf("\n");
+ printf("%hhu\n", 0x0123456789ABCDEll);
+ printf("%hu\n", 0x0123456789ABCDEll);
+ printf("%u\n", 0x0123456789ABCDEll);
+ printf("%lu\n", 0x0123456789ABCDEll);
+ printf("%llu\n", 0x0123456789ABCDEll);
+ printf("%Lu\n", 0x0123456789ABCDEll);
+ printf("\n");
+ printf("%zu\n", 0x0123456789ABCDEll);
+ printf("%ju\n", 0x0123456789ABCDEll);
+ printf("%tu\n", 0x0123456789ABCDEll);
+ printf("%qu\n", 0x0123456789ABCDEll);
+ printf("%Iu\n", 0x0123456789ABCDEll);
+ printf("\n");
+ printf("%hhx\n", -0x0123456789ABCDE);
+ printf("%hx\n", -0x0123456789ABCDE);
+ printf("%x\n", -0x0123456789ABCDE);
+ printf("%lx\n", -0x0123456789ABCDE);
+ printf("%llx\n", -0x0123456789ABCDE);
+ printf("%Lx\n", -0x0123456789ABCDE);
+ printf("\n");
+ printf("%hhx\n", -0x0123456789ABCDEl);
+ printf("%hx\n", -0x0123456789ABCDEl);
+ printf("%x\n", -0x0123456789ABCDEl);
+ printf("%lx\n", -0x0123456789ABCDEl);
+ printf("%llx\n", -0x0123456789ABCDEl);
+ printf("%Lx\n", -0x0123456789ABCDEl);
+ printf("\n");
+ printf("%hhx\n", -0x0123456789ABCDEll);
+ printf("%hx\n", -0x0123456789ABCDEll);
+ printf("%x\n", -0x0123456789ABCDEll);
+ printf("%lx\n", -0x0123456789ABCDEll);
+ printf("%llx\n", -0x0123456789ABCDEll);
+ printf("%Lx\n", -0x0123456789ABCDEll);
+ printf("\n");
+ printf("%zx\n", -0x0123456789ABCDEll);
+ printf("%jx\n", -0x0123456789ABCDEll);
+ printf("%tx\n", -0x0123456789ABCDEll);
+ printf("%qx\n", -0x0123456789ABCDEll);
+ printf("%Ix\n", -0x0123456789ABCDEll);
+ printf("\n");
+ printf("%hhd\n", -0x0123456789ABCDE);
+ printf("%hd\n", -0x0123456789ABCDE);
+ printf("%d\n", -0x0123456789ABCDE);
+ printf("%ld\n", -0x0123456789ABCDE);
+ printf("%lld\n", -0x0123456789ABCDE);
+ printf("%Ld\n", -0x0123456789ABCDE);
+ printf("\n");
+ printf("%hhd\n", -0x0123456789ABCDEl);
+ printf("%hd\n", -0x0123456789ABCDEl);
+ printf("%d\n", -0x0123456789ABCDEl);
+ printf("%ld\n", -0x0123456789ABCDEl);
+ printf("%lld\n", -0x0123456789ABCDEl);
+ printf("%Ld\n", -0x0123456789ABCDEl);
+ printf("\n");
+ printf("%hhd\n", -0x0123456789ABCDEll);
+ printf("%hd\n", -0x0123456789ABCDEll);
+ printf("%d\n", -0x0123456789ABCDEll);
+ printf("%ld\n", -0x0123456789ABCDEll);
+ printf("%lld\n", -0x0123456789ABCDEll);
+ printf("%Ld\n", -0x0123456789ABCDEll);
+ printf("\n");
+ printf("%zd\n", -0x0123456789ABCDEll);
+ printf("%jd\n", -0x0123456789ABCDEll);
+ printf("%td\n", -0x0123456789ABCDEll);
+ printf("%qd\n", -0x0123456789ABCDEll);
+ printf("%Id\n", -0x0123456789ABCDEll);
+ printf("\n");
+ printf("%hhu\n", -0x0123456789ABCDE);
+ printf("%hu\n", -0x0123456789ABCDE);
+ printf("%u\n", -0x0123456789ABCDE);
+ printf("%lu\n", -0x0123456789ABCDE);
+ printf("%llu\n", -0x0123456789ABCDE);
+ printf("%Lu\n", -0x0123456789ABCDE);
+ printf("\n");
+ printf("%hhu\n", -0x0123456789ABCDEl);
+ printf("%hu\n", -0x0123456789ABCDEl);
+ printf("%u\n", -0x0123456789ABCDEl);
+ printf("%lu\n", -0x0123456789ABCDEl);
+ printf("%llu\n", -0x0123456789ABCDEl);
+ printf("%Lu\n", -0x0123456789ABCDEl);
+ printf("\n");
+ printf("%hhu\n", -0x0123456789ABCDEll);
+ printf("%hu\n", -0x0123456789ABCDEll);
+ printf("%u\n", -0x0123456789ABCDEll);
+ printf("%lu\n", -0x0123456789ABCDEll);
+ printf("%llu\n", -0x0123456789ABCDEll);
+ printf("%Lu\n", -0x0123456789ABCDEll);
+ printf("\n");
+ printf("%zu\n", -0x0123456789ABCDEll);
+ printf("%ju\n", -0x0123456789ABCDEll);
+ printf("%tu\n", -0x0123456789ABCDEll);
+ printf("%qu\n", -0x0123456789ABCDEll);
+ printf("%Iu\n", -0x0123456789ABCDEll);
+ printf("\n");
+ printf("%hhf\n", 1234567.890123456789);
+ printf("%hf\n", 1234567.890123456789);
+ printf("%f\n", 1234567.890123456789);
+ printf("%lf\n", 1234567.890123456789);
+ printf("\n");
+ printf("%hhf\n", -1234567.890123456789);
+ printf("%hf\n", -1234567.890123456789);
+ printf("%f\n", -1234567.890123456789);
+ printf("%lf\n", -1234567.890123456789);
+ printf("\n");
+ printf("%hhf\n", 1234567.890123456789f);
+ printf("%hf\n", 1234567.890123456789f);
+ printf("%f\n", 1234567.890123456789f);
+ printf("%lf\n", 1234567.890123456789f);
+ printf("\n");
+ printf("%hhf\n", -1234567.890123456789f);
+ printf("%hf\n", -1234567.890123456789f);
+ printf("%f\n", -1234567.890123456789f);
+ printf("%lf\n", -1234567.890123456789f);
+ printf("\n");
+ printf("%hhu\n", 0);
+ printf("%hu\n", 0);
+ printf("%u\n", 0);
+ printf("%llu\n", 0ll);
+ printf("%hhx\n", 0);
+ printf("%hx\n", 0);
+ printf("%x\n", 0);
+ printf("%llx\n", 0ll);
+ printf("\n");
+ printf("%hhu\n", 1);
+ printf("%hu\n", 1);
+ printf("%u\n", 1);
+ printf("%llu\n", 1ll);
+ printf("%hhx\n", 1);
+ printf("%hx\n", 1);
+ printf("%x\n", 1);
+ printf("%llx\n", 1ll);
+ printf("\n");
+ printf("%hhu\n", -1);
+ printf("%hu\n", -1);
+ printf("%u\n", -1);
+ printf("%llu\n", -1ll);
+ printf("%hhx\n", -1);
+ printf("%hx\n", -1);
+ printf("%x\n", -1);
+ printf("%llx\n", -1ll);
+ printf("\n");
+ printf("%hhu\n", 0x7E);
+ printf("%hu\n", 0x7FFE);
+ printf("%u\n", 0x7FFFFFFE);
+ printf("%llu\n", 0x7FFFFFFFFFFE);
+ printf("%hhx\n", 0x7E);
+ printf("%hx\n", 0x7FFE);
+ printf("%x\n", 0x7FFFFFFE);
+ printf("%llx\n", 0x7FFFFFFFFFFE);
+ printf("\n");
+ printf("%hhu\n", 0x7F);
+ printf("%hu\n", 0x7FFF);
+ printf("%u\n", 0x7FFFFFFF);
+ printf("%llu\n", 0x7FFFFFFFFFFF);
+ printf("%hhx\n", 0x7F);
+ printf("%hx\n", 0x7FFF);
+ printf("%x\n", 0x7FFFFFFF);
+ printf("%llx\n", 0x7FFFFFFFFFFF);
+ printf("\n");
+ printf("%hhu\n", 0x80);
+ printf("%hu\n", 0x8000);
+ printf("%u\n", 0x8000000);
+ printf("%llu\n", 0x8000000000);
+ printf("%hhx\n", 0x80);
+ printf("%hx\n", 0x8000);
+ printf("%x\n", 0x8000000);
+ printf("%llx\n", 0x8000000000);
+ printf("\n");
+ printf("%hhu\n", 0xFF);
+ printf("%hu\n", 0xFFFF);
+ printf("%u\n", 0xFFFFFFFF);
+ printf("%llu\n", 0xFFFFFFFFFFFF);
+ printf("%hhx\n", 0xFF);
+ printf("%hx\n", 0xFFFF);
+ printf("%x\n", 0xFFFFFFFF);
+ printf("\n");
+ printf("%hhu\n", -0x7E);
+ printf("%hu\n", -0x7FFE);
+ printf("%u\n", -0x7FFFFFFE);
+ printf("%llu\n", -0x7FFFFFFFFFFE);
+ printf("%hhx\n", -0x7E);
+ printf("%hx\n", -0x7FFE);
+ printf("%x\n", -0x7FFFFFFE);
+ printf("%llx\n", -0x7FFFFFFFFFFE);
+ printf("\n");
+ printf("%hhu\n", -0x7F);
+ printf("%hu\n", -0x7FFF);
+ printf("%u\n", -0x7FFFFFFF);
+ printf("%llu\n", -0x7FFFFFFFFFFF);
+ printf("%hhx\n", -0x7F);
+ printf("%hx\n", -0x7FFF);
+ printf("%x\n", -0x7FFFFFFF);
+ printf("%llx\n", -0x7FFFFFFFFFFF);
+ printf("\n");
+ printf("%hhu\n", -0x80);
+ printf("%hu\n", -0x8000);
+ printf("%u\n", -0x8000000);
+ printf("%llu\n", -0x8000000000);
+ printf("%hhx\n", -0x80);
+ printf("%hx\n", -0x8000);
+ printf("%x\n", -0x8000000);
+ printf("%llx\n", -0x8000000000);
+ printf("\n");
+ printf("%hhu\n", -0xFF);
+ printf("%hu\n", -0xFFFF);
+ printf("%u\n", -0xFFFFFFFF);
+ printf("%llu\n", -0xFFFFFFFFFFFF);
+ printf("%hhx\n", -0xFF);
+ printf("%hx\n", -0xFFFF);
+ printf("%x\n", -0xFFFFFFFF);
return 0;
}