MCPcopy Create free account
hub / github.com/IntegralPilot/wasm_os / llitoa

Function llitoa

stdlib/cpp/iostream.hpp:58–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56 }
57
58 void llitoa(long long int num, char* str) {
59 int i = 0;
60 int isNegative = 0;
61
62 if (num == 0) {
63 str[i++] = '0';
64 str[i] = '\0';
65 return;
66 }
67
68 if (num < 0) {
69 isNegative = 1;
70 num = -num;
71 }
72
73 while (num != 0) {
74 int rem = num % 10;
75 str[i++] = rem + '0';
76 num = num / 10;
77 }
78
79 if (isNegative)
80 str[i++] = '-';
81
82 str[i] = '\0';
83
84 // Reverse the string
85 int start = 0;
86 int end = i - 1;
87 while (start < end) {
88 char temp = str[start];
89 str[start] = str[end];
90 str[end] = temp;
91 start++;
92 end--;
93 }
94 }
95
96 void litoa(long int num, char* str) {
97 int i = 0;

Callers 1

ostreamClass · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected