-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patht.q
More file actions
36 lines (32 loc) · 1.47 KB
/
Copy patht.q
File metadata and controls
36 lines (32 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
([printf]):use`..printf;
/ Integers
1 printf("%d\n"; 42); / simple integer
1 printf("%5d\n"; 42); / width > length
1 printf("%05d\n"; 42); / zero-padding
1 printf("%-5d\n"; 42); / left-align
1 printf("%+5d\n"; 42); / plus sign
1 printf("% 5d\n"; 42); / space sign
/ Floats
1 printf("%f\n"; 3.14159); / simple float
1 printf("%8.2f\n"; 3.14159); / width and precision
1 printf("%08.2f\n"; 3.14159); / zero-padding with float
1 printf("%-8.2f\n"; 3.14159); / left-align float
1 printf("%+8.2f\n"; 3.14159); / plus sign with float
/ Hex / Octal
1 printf("%x\n"; 255); / hex lowercase
1 printf("%X\n"; 255); / hex uppercase
1 printf("%5x\n"; 255); / width with hex
1 printf("%05x\n"; 255); / zero-padding hex
1 printf("%5X\n"; 255); / width with hex
1 printf("%05X\n"; 255); / zero-padding hex
1 printf("%o\n"; 255); / octal
1 printf("%5o\n"; 255); / width octal
1 printf("%05o\n"; 255); / zero-padding octal
/ Strings / repr
1 printf("%s\n"; "hello world"); / string
1 printf("%8s\n"; "hi"); / string width
1 printf("%-8s\n"; "hi"); / left-align string
1 printf("%r\n"; 1+2); / repr
/ Literal percent
1 printf("%%\n"); / prints %
exit 0;