1

could any please explain the below code

const uInt32 eVal = 8ul;
const uInt32 fVal = 5ul;
const uInt32 zVal = 0ul;

what does ul and numbers 8,5,0 are stand for

cybergeeeek
  • 410
  • 8
  • 22
  • Possible duplicate of [what is the reason for explicitly declaring L or UL for long values](https://stackoverflow.com/questions/13134956/what-is-the-reason-for-explicitly-declaring-l-or-ul-for-long-values) – Undefined Behaviour Dec 07 '17 at 10:45

2 Answers2

4

It's the programmer being unnecessarily verbose. ul is the prefix for an unsigned long literal, so 8ul has an unsigned long type.

Most likely, that isn't the same type as the uInt32, so really the code you present is an exercise in obfuscation. Really they should rely on the automatic implicit conversion rules and write

const uInt32 eVal = 8;
const uInt32 fVal = 5;
const uInt32 zVal = 0;

perhaps even preferring constexpr in place of const.

Reference: http://en.cppreference.com/w/cpp/language/implicit_conversion

Bathsheba
  • 231,907
  • 34
  • 361
  • 483
2

ul stands for unsigned long representation of numbers. Here the number 8 or 5 or 0 of type unsigned long is being assigned to constant uInt32 type variable.

The 'ul' is used for representation. It need not be used also.