Index: boot/generic/src/printf_core.c
===================================================================
--- boot/generic/src/printf_core.c	(revision 7ce7cfb9dc6103aa81592c5d0fcc2bb4e177056e)
+++ boot/generic/src/printf_core.c	(revision 7fadb6526b88d8a8d0bbeb5d5997969a53e7e66d)
@@ -70,4 +70,23 @@
  */
 #define PRINT_NUMBER_BUFFER_SIZE  (64 + 5)
+
+/** Get signed or unsigned integer argument */
+#define PRINTF_GET_INT_ARGUMENT(type, ap, flags) \
+	({ \
+		unsigned type res; \
+		\
+		if ((flags) & __PRINTF_FLAG_SIGNED) { \
+			signed type arg = va_arg((ap), signed type); \
+			\
+			if (arg < 0) { \
+				res = -arg; \
+				(flags) |= __PRINTF_FLAG_NEGATIVE; \
+			} else \
+				res = arg; \
+		} else \
+			res = va_arg((ap), unsigned type); \
+		\
+		res; \
+	})
 
 /** Enumeration of possible arguments types.
@@ -171,5 +190,5 @@
 	}
 	
-	return (int) (counter + 1);
+	return (int) (counter);
 }
 
@@ -698,24 +717,25 @@
 			size_t size;
 			uint64_t number;
+			
 			switch (qualifier) {
 			case PrintfQualifierByte:
 				size = sizeof(unsigned char);
-				number = (uint64_t) va_arg(ap, unsigned int);
+				number = PRINTF_GET_INT_ARGUMENT(int, ap, flags);
 				break;
 			case PrintfQualifierShort:
 				size = sizeof(unsigned short);
-				number = (uint64_t) va_arg(ap, unsigned int);
+				number = PRINTF_GET_INT_ARGUMENT(int, ap, flags);
 				break;
 			case PrintfQualifierInt:
 				size = sizeof(unsigned int);
-				number = (uint64_t) va_arg(ap, unsigned int);
+				number = PRINTF_GET_INT_ARGUMENT(int, ap, flags);
 				break;
 			case PrintfQualifierLong:
 				size = sizeof(unsigned long);
-				number = (uint64_t) va_arg(ap, unsigned long);
+				number = PRINTF_GET_INT_ARGUMENT(long, ap, flags);
 				break;
 			case PrintfQualifierLongLong:
 				size = sizeof(unsigned long long);
-				number = (uint64_t) va_arg(ap, unsigned long long);
+				number = PRINTF_GET_INT_ARGUMENT(long long, ap, flags);
 				break;
 			case PrintfQualifierPointer:
@@ -732,20 +752,4 @@
 				counter = -counter;
 				goto out;
-			}
-			
-			if (flags & __PRINTF_FLAG_SIGNED) {
-				if (number & (0x1 << (size * 8 - 1))) {
-					flags |= __PRINTF_FLAG_NEGATIVE;
-					
-					if (size == sizeof(uint64_t)) {
-						number = -((int64_t) number);
-					} else {
-						number = ~number;
-						number &=
-						    ~(0xFFFFFFFFFFFFFFFFll <<
-						    (size * 8));
-						number++;
-					}
-				}
 			}
 			
Index: kernel/generic/src/printf/printf_core.c
===================================================================
--- kernel/generic/src/printf/printf_core.c	(revision 7ce7cfb9dc6103aa81592c5d0fcc2bb4e177056e)
+++ kernel/generic/src/printf/printf_core.c	(revision 7fadb6526b88d8a8d0bbeb5d5997969a53e7e66d)
@@ -75,4 +75,23 @@
 #define PRINT_NUMBER_BUFFER_SIZE  (64 + 5)
 
+/** Get signed or unsigned integer argument */
+#define PRINTF_GET_INT_ARGUMENT(type, ap, flags) \
+	({ \
+		unsigned type res; \
+		\
+		if ((flags) & __PRINTF_FLAG_SIGNED) { \
+			signed type arg = va_arg((ap), signed type); \
+			\
+			if (arg < 0) { \
+				res = -arg; \
+				(flags) |= __PRINTF_FLAG_NEGATIVE; \
+			} else \
+				res = arg; \
+		} else \
+			res = va_arg((ap), unsigned type); \
+		\
+		res; \
+	})
+
 /** Enumeration of possible arguments types.
  */
@@ -207,5 +226,5 @@
 	}
 	
-	return (int) (counter + 1);
+	return (int) (counter);
 }
 
@@ -245,5 +264,5 @@
 	}
 	
-	return (int) (counter + 1);
+	return (int) (counter);
 }
 
@@ -832,24 +851,25 @@
 			size_t size;
 			uint64_t number;
+			
 			switch (qualifier) {
 			case PrintfQualifierByte:
 				size = sizeof(unsigned char);
-				number = (uint64_t) va_arg(ap, unsigned int);
+				number = PRINTF_GET_INT_ARGUMENT(int, ap, flags);
 				break;
 			case PrintfQualifierShort:
 				size = sizeof(unsigned short);
-				number = (uint64_t) va_arg(ap, unsigned int);
+				number = PRINTF_GET_INT_ARGUMENT(int, ap, flags);
 				break;
 			case PrintfQualifierInt:
 				size = sizeof(unsigned int);
-				number = (uint64_t) va_arg(ap, unsigned int);
+				number = PRINTF_GET_INT_ARGUMENT(int, ap, flags);
 				break;
 			case PrintfQualifierLong:
 				size = sizeof(unsigned long);
-				number = (uint64_t) va_arg(ap, unsigned long);
+				number = PRINTF_GET_INT_ARGUMENT(long, ap, flags);
 				break;
 			case PrintfQualifierLongLong:
 				size = sizeof(unsigned long long);
-				number = (uint64_t) va_arg(ap, unsigned long long);
+				number = PRINTF_GET_INT_ARGUMENT(long long, ap, flags);
 				break;
 			case PrintfQualifierPointer:
@@ -866,20 +886,4 @@
 				counter = -counter;
 				goto out;
-			}
-			
-			if (flags & __PRINTF_FLAG_SIGNED) {
-				if (number & (0x1 << (size * 8 - 1))) {
-					flags |= __PRINTF_FLAG_NEGATIVE;
-					
-					if (size == sizeof(uint64_t)) {
-						number = -((int64_t) number);
-					} else {
-						number = ~number;
-						number &=
-						    ~(0xFFFFFFFFFFFFFFFFll <<
-						    (size * 8));
-						number++;
-					}
-				}
 			}
 			
Index: kernel/test/print/print2.c
===================================================================
--- kernel/test/print/print2.c	(revision 7ce7cfb9dc6103aa81592c5d0fcc2bb4e177056e)
+++ kernel/test/print/print2.c	(revision 7fadb6526b88d8a8d0bbeb5d5997969a53e7e66d)
@@ -44,4 +44,8 @@
 	TPRINTF("Real output:     [%d] [%3.2d] [%-3.2d] [%2.3d] [%-2.3d]\n\n", -1, -2, -3, -4, -5);
 	
+	TPRINTF("Testing printf(\"%%lld %%3.2lld %%-3.2lld %%2.3lld %%-2.3lld\", (long long) -1, (long long) -2, (long long) -3, (long long) -4, (long long) -5):\n");
+	TPRINTF("Expected output: [-1] [-02] [-03] [-004] [-005]\n");
+	TPRINTF("Real output:     [%lld] [%3.2lld] [%-3.2lld] [%2.3lld] [%-2.3lld]\n\n", (long long) -1, (long long) -2, (long long) -3, (long long) -4, (long long) -5);
+	
 	TPRINTF("Testing printf(\"%%#x %%5.3#x %%-5.3#x %%3.5#x %%-3.5#x\", 17, 18, 19, 20, 21):\n");
 	TPRINTF("Expected output: [0x11] [0x012] [0x013] [0x00014] [0x00015]\n");
Index: uspace/app/tester/print/print2.c
===================================================================
--- uspace/app/tester/print/print2.c	(revision 7ce7cfb9dc6103aa81592c5d0fcc2bb4e177056e)
+++ uspace/app/tester/print/print2.c	(revision 7fadb6526b88d8a8d0bbeb5d5997969a53e7e66d)
@@ -45,4 +45,8 @@
 	TPRINTF("Real output:     [%d] [%3.2d] [%-3.2d] [%2.3d] [%-2.3d]\n\n", -1, -2, -3, -4, -5);
 	
+	TPRINTF("Testing printf(\"%%lld %%3.2lld %%-3.2lld %%2.3lld %%-2.3lld\", (long long) -1, (long long) -2, (long long) -3, (long long) -4, (long long) -5):\n");
+	TPRINTF("Expected output: [-1] [-02] [-03] [-004] [-005]\n");
+	TPRINTF("Real output:     [%lld] [%3.2lld] [%-3.2lld] [%2.3lld] [%-2.3lld]\n\n", (long long) -1, (long long) -2, (long long) -3, (long long) -4, (long long) -5);
+	
 	TPRINTF("Testing printf(\"%%#x %%5.3#x %%-5.3#x %%3.5#x %%-3.5#x\", 17, 18, 19, 20, 21):\n");
 	TPRINTF("Expected output: [0x11] [0x012] [0x013] [0x00014] [0x00015]\n");
Index: uspace/lib/c/generic/io/printf_core.c
===================================================================
--- uspace/lib/c/generic/io/printf_core.c	(revision 7ce7cfb9dc6103aa81592c5d0fcc2bb4e177056e)
+++ uspace/lib/c/generic/io/printf_core.c	(revision 7fadb6526b88d8a8d0bbeb5d5997969a53e7e66d)
@@ -73,4 +73,23 @@
  */
 #define PRINT_NUMBER_BUFFER_SIZE  (64 + 5)
+
+/** Get signed or unsigned integer argument */
+#define PRINTF_GET_INT_ARGUMENT(type, ap, flags) \
+	({ \
+		unsigned type res; \
+		\
+		if ((flags) & __PRINTF_FLAG_SIGNED) { \
+			signed type arg = va_arg((ap), signed type); \
+			\
+			if (arg < 0) { \
+				res = -arg; \
+				(flags) |= __PRINTF_FLAG_NEGATIVE; \
+			} else \
+				res = arg; \
+		} else \
+			res = va_arg((ap), unsigned type); \
+		\
+		res; \
+	})
 
 /** Enumeration of possible arguments types.
@@ -831,24 +850,25 @@
 			size_t size;
 			uint64_t number;
+			
 			switch (qualifier) {
 			case PrintfQualifierByte:
 				size = sizeof(unsigned char);
-				number = (uint64_t) va_arg(ap, unsigned int);
+				number = PRINTF_GET_INT_ARGUMENT(int, ap, flags);
 				break;
 			case PrintfQualifierShort:
 				size = sizeof(unsigned short);
-				number = (uint64_t) va_arg(ap, unsigned int);
+				number = PRINTF_GET_INT_ARGUMENT(int, ap, flags);
 				break;
 			case PrintfQualifierInt:
 				size = sizeof(unsigned int);
-				number = (uint64_t) va_arg(ap, unsigned int);
+				number = PRINTF_GET_INT_ARGUMENT(int, ap, flags);
 				break;
 			case PrintfQualifierLong:
 				size = sizeof(unsigned long);
-				number = (uint64_t) va_arg(ap, unsigned long);
+				number = PRINTF_GET_INT_ARGUMENT(long, ap, flags);
 				break;
 			case PrintfQualifierLongLong:
 				size = sizeof(unsigned long long);
-				number = (uint64_t) va_arg(ap, unsigned long long);
+				number = PRINTF_GET_INT_ARGUMENT(long long, ap, flags);
 				break;
 			case PrintfQualifierPointer:
@@ -865,20 +885,4 @@
 				counter = -counter;
 				goto out;
-			}
-			
-			if (flags & __PRINTF_FLAG_SIGNED) {
-				if (number & (0x1 << (size * 8 - 1))) {
-					flags |= __PRINTF_FLAG_NEGATIVE;
-					
-					if (size == sizeof(uint64_t)) {
-						number = -((int64_t) number);
-					} else {
-						number = ~number;
-						number &=
-						    ~(0xFFFFFFFFFFFFFFFFll <<
-						    (size * 8));
-						number++;
-					}
-				}
 			}
 			
