You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Assuming we don't want to depart from POSIX behavior in our sprintf function.
The # flag with %o and precision is described in Perl 6 Documentation to follow POSIX by conditionally padding beyond the given precision, only if necessary to preserve the c-style 0-prefix on the octal output.
My linux stdio lib follows this behavior:
doug@ender:~/study/Perl6$ echo -e '#include <stdio.h>\n#include <iostream>\nusing namespace std;\n
int main() { char* s = new char[10]; sprintf(s, "%#.5o\\n", 012345); cout<<s; }' | gcc -x c++ -lstdc++ - ; ./a.out
012345
doug@ender:~/study/Perl6$ echo -e '#include <stdio.h>\n#include <iostream>\nusing namespace std;\n
int main() { char* s = new char[10]; sprintf(s, "%.5o\\n", 012345); cout<<s; }' | gcc -x c++ -lstdc++ - ; ./a.out
12345
doug@ender:~/study/Perl6$ echo -e '#include <stdio.h>\n#include <iostream>\nusing namespace std;\n
int main() { char* s = new char[10]; sprintf(s, "%#.5o\\n", 0123); cout<<s; }' | gcc -x c++ -lstdc++ - ; ./a.out
00123
doug@ender:~/study/Perl6$ echo -e '#include <stdio.h>\n#include <iostream>\nusing namespace std;\n
int main() { char* s = new char[10]; sprintf(s, "%.5o\\n", 0123); cout<<s; }' | gcc -x c++ -lstdc++ - ; ./a.out
00123
Assuming we don't want to depart from POSIX behavior in our sprintf function.
The
#flag with%oand precision is described in Perl 6 Documentation to follow POSIX by conditionally padding beyond the given precision, only if necessary to preserve the c-style 0-prefix on the octal output.My linux stdio lib follows this behavior:
However, Rakudo Perl6 departs from this behavior:
The text was updated successfully, but these errors were encountered: