Literal Qualifiers

Much like variables, literals may be qualified to force the compiler to treat them as a specific data type.

Qualifiers are specified by adding a suffix to the value.

  • U or u for unsigned: 25u
  • L (preferred) or l for long: 25L
  • F or f for float: 10f or 10.25f

The U and L suffixes may be combined to create an unsigned long literal: 0xF5UL but U must always precede L.

Why Are Qualifiers Needed?

Integers without a suffix are assumed to be signed and short. This has some implications with respect to arithmetic operations that will be discussed throughout the section on operators.

Also, a number like 10 will be interpreted as an integer. However, in some arithmetic expressions it may be necessary to force the compiler to treat it as a floating point value to get the desired result.

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.