Skip to content

Commit 03301f8

Browse files
authored
Update print.md (#1597)
On the website, there are two options listed for hexadecimal. I was confused what the difference between the capital x and X was but then I ran it through and realized the latter capitalized the letters. I've also done the courtesy of listing out their subsequent results. I also added some additional information to the "width" section and formatted it for easier readability.
1 parent 3a5ffcb commit 03301f8

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/hello/print.md

+11-8
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,20 @@ fn main() {
3131
3232
// Different formatting can be invoked by specifying the format character after a
3333
// `:`.
34-
println!("Base 10 repr: {}", 69420);
35-
println!("Base 2 (binary) repr: {:b}", 69420);
36-
println!("Base 8 (octal) repr: {:o}", 69420);
37-
println!("Base 16 (hexadecimal) repr: {:x}", 69420);
34+
println!("Base 10: {}", 69420); //69420
35+
println!("Base 2 (binary): {:b}", 69420); //10000111100101100
36+
println!("Base 8 (octal): {:o}", 69420); //207454
37+
println!("Base 16 (hexadecimal): {:x}", 69420); //10f2c
38+
println!("Base 16 (hexadecimal): {:X}", 69420); //10F2C
3839
39-
// You can right-align text with a specified width. This will output
40-
// " 1". 4 white spaces and a "1", for a total width of 5.
40+
41+
// You can right-justify text with a specified width. This will
42+
// output " 1". (Four white spaces and a "1", for a total width of 5.)
4143
println!("{number:>5}", number=1);
4244
43-
// You can pad numbers with extra zeroes. This will output "00001".
44-
println!("{number:0>5}", number=1);
45+
// You can pad numbers with extra zeroes,
46+
//and left-adjust by flipping the sign. This will output "10000".
47+
println!("{number:0<5}", number=1);
4548
4649
// You can use named arguments in the format specifier by appending a `$`
4750
println!("{number:0>width$}", number=1, width=5);

0 commit comments

Comments
 (0)