aboutsummaryrefslogtreecommitdiff
path: root/exercises
diff options
context:
space:
mode:
authorDave Gauer <dave@ratfactor.com>2021-04-08 18:42:19 -0400
committerDave Gauer <dave@ratfactor.com>2021-04-08 18:42:19 -0400
commite9cf13bce8d3bfc59542f0b59764a6c46756543a (patch)
treed6c67aeffaf01e2121b7e4001ec501741ecbf141 /exercises
parent74221f2fb2f32b52e51ffe1af4572a8940229b96 (diff)
downloadziglings-e9cf13bce8d3bfc59542f0b59764a6c46756543a.tar.gz
ziglings-e9cf13bce8d3bfc59542f0b59764a6c46756543a.tar.bz2
ziglings-e9cf13bce8d3bfc59542f0b59764a6c46756543a.tar.xz
ziglings-e9cf13bce8d3bfc59542f0b59764a6c46756543a.zip
added 059
Diffstat (limited to 'exercises')
-rw-r--r--exercises/059_integers.zig28
1 files changed, 28 insertions, 0 deletions
diff --git a/exercises/059_integers.zig b/exercises/059_integers.zig
new file mode 100644
index 0000000..e72fa2f
--- /dev/null
+++ b/exercises/059_integers.zig
@@ -0,0 +1,28 @@
+//
+// Zig lets you express integer literals in several convenient
+// formats. These are all the same value:
+//
+// const a1: u8 = 65; // decimal
+// const a2: u8 = 0x41; // hexadecimal
+// const a3: u8 = 0o101; // octal
+// const a4: u8 = 0b1000001; // binary
+// const a5: u8 = 'A'; // UTF-8 code point literal
+//
+// You can also place underscores in numbers to aid readability:
+//
+// const t1: u32 = 14_689_520 // Ford Model T sales 1909-1927
+// const t2: u32 = 0xE0_24_F0 // same, in hex pairs
+//
+// Please fix the message:
+
+const print = @import("std").debug.print;
+
+pub fn main() void {
+ var zig = [_]u8 {
+ 0o131, // octal
+ 0b1101000, // binary
+ 0x66, // hex
+ };
+
+ print("{s} is cool.\n", .{zig});
+}