vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

cpp_numbers.cpp (941B)


      1 #include <stdfloat>
      2 
      3 void foo()
      4 {
      5     {
      6         // See https://en.cppreference.com/w/cpp/language/floating_literal
      7         double a = 1.0E2;
      8         double b = 1.0e2;
      9         double c = 1E2;
     10         double d = 1e2;
     11 
     12         double e = 0X.1ffP10;
     13         float f = 0xFFp+2F;
     14         double g = 0x67.P-2;
     15         long double h = 0x1'2.f'fp-1'0L;
     16 
     17         // extended floating-point types (since C++23)
     18         std::float16_t f16 = 1.0F16;
     19         std::float32_t f32 = .1'2e+3'4f32;
     20         std::float64_t f64 = -0.123'456F64;
     21         std::float128_t f128 = +0x1'23.A'BCp-1'234f128;
     22         std::bfloat16_t bf16 = 0X1P-7BF16;
     23     }
     24 
     25     // See: https://en.cppreference.com/w/cpp/language/integer_literal
     26     int a = 0X123;
     27     int b = 0x123;
     28 
     29     int c = 0B101;
     30     int d = 0b101;
     31 
     32     // size_t suffix (since C++23)
     33     {
     34         auto dec = 123Z;
     35         auto bin = 0B10'10ZU;
     36         auto oct = 01'750Uz;
     37         auto hex = 0x12'EFz;
     38     }
     39 }