059_integers.zig 789 B

12345678910111213141516171819202122232425262728
  1. //
  2. // Zig lets you express integer literals in several convenient
  3. // formats. These are all the same value:
  4. //
  5. // const a1: u8 = 65; // decimal
  6. // const a2: u8 = 0x41; // hexadecimal
  7. // const a3: u8 = 0o101; // octal
  8. // const a4: u8 = 0b1000001; // binary
  9. // const a5: u8 = 'A'; // UTF-8 code point literal
  10. //
  11. // You can also place underscores in numbers to aid readability:
  12. //
  13. // const t1: u32 = 14_689_520 // Ford Model T sales 1909-1927
  14. // const t2: u32 = 0xE0_24_F0 // same, in hex pairs
  15. //
  16. // Please fix the message:
  17. const print = @import("std").debug.print;
  18. pub fn main() void {
  19. var zig = [_]u8 {
  20. 0o131, // octal
  21. 0b1101000, // binary
  22. 0x66, // hex
  23. };
  24. print("{s} is cool.\n", .{zig});
  25. }