print uint32_t variable different?

I tried print a variable declared as uint32_t and print.
But print result is different with I think.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
QW09:~/cpp_test$ vim print_magic.cc

include <iostream>
#include <stdint.h>
using namespace std;

uint32_t const SUPERBLOCK_MAGIC = 06142003;

int main() {
    cout << "super = " << SUPERBLOCK_MAGIC << endl;

    return 0;
}


Print result:

1
2
3
QW09:~/cpp_test$ g++ print_magic.cc -o print_magic
QW09:~/cpp_test$ ./print_magic 
super = 1623043
> uint32_t const SUPERBLOCK_MAGIC = 06142003;
Try it without a leading zero.

This makes the number octal (base 8), not decimal.

Octal is the less well known cousin to hexadecimal, which you specify with a leading 0x.
Do you realize that a number starting with zero is usually treated as Octal not decimal?

Thanks.
I don't know add leading zero will convert to base8.
Topic archived. No new replies allowed.