Looking through boost random library I've come across literal something like 331u. Does anyone can explain to me what this u is about?

void seed(uint32_t value = 331u);

Thank you

It means it's an unsigned integer, to match the type of value.

Found from the web:

u8 unsigned byte (8 bits)
u16 unsigned word (16 bits)
u32 unsigned 32-bit value
u64 unsigned 64-bit value
s8 signed byte (8 bits)
s16 signed word (16 bits)
s32 signed 32-bit value
s64 signed 64-bit value

There's more, but I'm sure you get the picture.

Edited 7 Years Ago by William Hemsworth: n/a

Looking through boost random library I've come across literal something like 331u. Does anyone can explain to me what this u is about?

void seed(uint32_t value = 331u);

Thank you

http://web.archive.org/web/20050207005628/http://dev.unicals.com/papers/c89-draft.html#unsigned-suffix

The type of an integer constant is the first of the corresponding list in which its value can be represented. Unsuffixed decimal: int, long int, unsigned long int; unsuffixed octal or hexadecimal: int, unsigned int, long int, unsigned long int; suffixed by the letter u or U: unsigned int, unsigned long int; suffixed by the letter l or L: long int, unsigned long int; suffixed by both the letters u or U and l or L: unsigned long int .

This question has already been answered. Start a new discussion instead.