The record itself:

#define FLT_EPSILON 1.19209290E-07F 

What

 #define 

and I know the name, but what it means is 1.19209290E-07F. Explain, please.

    2 answers 2

     #define FLT_EPSILON 1.19209290E-07F 

    it's a legacy of si. At the moment it is better to write like this

     const float FLT_EPSILON = 1.19209290E-07F; 

    In most cases, these entries are equivalent in functionality.

    #define is a preprocessor directive that simply means replacing one piece of text with another. The preprocessor works even before the compiler (although now it happens in almost one process) and can sometimes give wonderful results. For example, my favorite

     #define true false 

    and all occurrences of true as words will be replaced with false ( bool a = true; will be replaced with bool a = false; but true1 will not.)

    At define there is one feature - they do not know anything about areas of visibility and work from the place of the announcement to the end of the file. That is why it is very interesting to observe how windows.h substitutes max / min and causes errors.

    Although define is terrible, they give a lot of mistakes, but sometimes they allow you to solve problems elegantly and beautifully.

    The letter F at the end is just a literal . Such a way to clarify the type of the variable (after all, the default 1.0 is double). The new C ++ has the opportunity to create your own literals .

    • Actually, const is from a completely different opera. Use instead of #define can not const , and constexpr . - freim
    • one
      Already the second answer, which calls F literal. :) The literal is the whole number. - HolyBlackCat 7:07
    • clarifying letter of the literal - KoVadim
    • @freim, but constexpr is not needed here. From the word at all. In general, as the disassembler shows, the compiler will make the code worse. - KoVadim
    • @KoVadim, you need constexpr here or do not need another question. To say that #define and const equivalent in functionality is simply wrong. Even constexpr not equivalent to #define in functionality, but at least there is some kind of correspondence. - freim

    1.19209290E-07 is a floating point number (1.19209290 * 10 ^ -7), the suffix F at the end indicates that the number is of type float

    • In case the questioner is not obvious, instead - there could be + (or nothing, which means the same thing). - HolyBlackCat