Search⌘ K
AI Features

Integer and Floating Point Literals

Explore how to use integer and floating point literals in D programming. Understand different numeral systems like decimal, hexadecimal, and binary, and learn how the compiler infers and handles literal types. This lesson will build your foundation for writing precise numeric values in your code.

Literals

Programs achieve their tasks by manipulating the values of variables. They produce new values by using them with functions and operators.
Some values, however, need not be modified during the execution of the program. Instead, they are used as-is in the source code. For example, the floating point value 0.75 and the string value "Total price: " below are not calculated by the program:

discountedPrice = actualPrice * 0.75;  
totalPrice += count * discountedPrice;  
writeln("Total price: ", totalPrice);

Such values, which directly typed into the source code, are called literals. We have used string literals in the programs so far. Now, we will see other types of ...