059_integers.zig 861 B

1234567891011121314151617181920212223242526272829
  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'; // ASCII code point literal
  10. // const a6: u16 = 'Ȁ'; // Unicode code points can take up to 21 bits
  11. //
  12. // You can also place underscores in numbers to aid readability:
  13. //
  14. // const t1: u32 = 14_689_520 // Ford Model T sales 1909-1927
  15. // const t2: u32 = 0xE0_24_F0 // same, in hex pairs
  16. //
  17. // Please fix the message:
  18. const print = @import("std").debug.print;
  19. pub fn main() void {
  20. const zig = [_]u8{
  21. 0o131, // octal
  22. 0b1101000, // binary
  23. 0x66, // hex
  24. };
  25. print("{s} is cool.\n", .{zig});
  26. }