{"id":427466,"date":"2024-07-26T09:01:07","date_gmt":"2024-07-26T09:01:07","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=427466"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=427466","title":{"rendered":"<span>\u0418\u0433\u0440\u0443\u0448\u0435\u0447\u043d\u0430\u044f \u0438\u043c\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u0441 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u0432 C++<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1dc\/876\/170\/1dc8761701612d6f35fb7427b2945093.webp\" width=\"1024\" height=\"1024\"\/><\/figure>\n<p>\u0412 C++ \u043d\u0435\u0442 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e<a href=\"https:\/\/en.wikipedia.org\/wiki\/Fixed-point_arithmetic\" rel=\"noopener noreferrer nofollow\"> \u0442\u0438\u043f\u0430 \u0447\u0438\u0441\u0435\u043b \u0441 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439<\/a>, \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u0442 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0434\u043b\u044f \u043d\u0438\u0445. \u0412 \u0442\u043e\u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 (double, float) \u0447\u0430\u0441\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0442\u0432\u0435\u0442\u044c\u0442\u0435 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441: \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u0430 \u043b\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u0434 \u043d\u0438\u043c\u0438?), \u0432\u0434\u043e\u0431\u0430\u0432\u043e\u043a \u044f\u0437\u044b\u043a \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 (\u0447\u0430\u0441\u0442\u043e \u043a\u0440\u0438\u0442\u0438\u043a\u0443\u0435\u043c\u0443\u044e) \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u0430\u0440\u0438\u0444\u043c\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u043f\u043e\u0434\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044f \u043d\u0430\u0441 \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u043c \u043c\u0430\u0442. \u0447\u0430\u0441\u0442\u044c, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u0435\u043b \u0432 \u0442\u0438\u043f\u0430\u0445 uint8_t, int8_t \u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u0445 \u0430\u0440\u0438\u0444\u043c\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u0445 \u043d\u0430\u0434 \u043d\u0438\u043c\u0438. \u0418\u0442\u0430\u043a, \u0441\u043b\u043e\u0436\u0435\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 uint8_t \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e 256, \u0442\u043e \u0435\u0441\u0442\u044c 1+2 = 3, \u043d\u043e 1 + 255 = 0, \u0434\u043b\u044f int8_t  \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0432\u0432\u0435\u0441\u0442\u0438 \u0441\u043b\u0435\u0434\u0443\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u0443\u044e\u0442 \u0442\u0435\u043c \u0431\u0435\u0437\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u0447\u0438\u0441\u043b\u0430\u043c \u0438\u0437 uint8_t \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044f\u0441\u044c \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e 256 \u0434\u0430\u0434\u0443\u0442 \u043d\u043e\u043b\u044c, \u0442\u043e \u0435\u0441\u0442\u044c -1 \u0431\u0443\u0434\u0435\u043c \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442\u044c \u043a\u0430\u043a 255 (FF). \u0413\u0440\u0430\u043d\u0438\u0446\u044b \u0442\u0438\u043f\u0430 int8_t  -128&#8230;+127, \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0431\u0438\u0442 \u0432\u0441\u0435\u0433\u0434\u0430 \u0440\u0430\u0432\u0435\u043d 1. \u041f\u0440\u0438 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0438 \u0434\u0432\u0443\u0445 int8_t \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u0438\u043f\u0430 int16_t, \u0447\u0430\u0441\u0442\u043d\u043e\u0435 \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f int16_t \u043d\u0430 uint8_t \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0442\u0438\u043f uint8_t. \u0412\u0441\u0435 \u044d\u0442\u0438 \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043d\u043e\u0441\u044f\u0442 \u0430\u0431\u043e\u043b\u044e\u0442\u043d\u043e \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440, \u043d\u043e, \u043e\u043d\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0438\u0434\u0435\u0435: \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 int8_t \u0438 \u0441\u043a\u0430\u0436\u0435\u043c, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e \u043d\u0435 \u0447\u0438\u0441\u043b\u043e \u0435\u0434\u0438\u043d\u0438\u0446, \u0430 \u0441\u043a\u0430\u0436\u0435\u043c, \u0447\u0438\u0441\u043b\u043e 1\/4 (\u043f\u0440\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0441\u043b\u043e\u0432\u0430\u043c\u0438: \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u0447\u0438\u0441\u043b\u0435)? \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u0435\u043c \u044d\u0442\u0443 \u043f\u0435\u0440\u043c\u0435\u043d\u043d\u0443\u044e \u0432 \u043f\u043e\u043b\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u0438\u043c \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0430\u0440\u0438\u0444\u043c\u0438\u0442\u0438\u0447\u0435\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0439 operator string() \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430 \u0442\u0430\u043a\u0438\u0445 \u0447\u0438\u0441\u0435\u043b.  \u041d\u0438\u0436\u0435, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u044d\u0442\u043e\u0439 \u0438\u0434\u0435\u0438.<\/p>\n<pre><code class=\"cpp\">#include &lt;stdexcept&gt; #include &lt;cmath&gt; #include &lt;climits&gt; #include &lt;iostream&gt; #include &lt;sstream&gt; #include &lt;iomanip&gt;  template &lt;typename T&gt; constexpr T ipow(T num, unsigned int pow) {     return (pow &gt;= sizeof(unsigned int)*8) ? 0 :                pow == 0 ? 1 : num * ipow(num, pow-1); }  \/\/ fills and return given number of ones in the least significant bits of a byte constexpr uint8_t mask(uint8_t num) {     return num == 0 ? 0 : (mask(num - 1) &lt;&lt; 1) | 1; }  \/\/ FractionLength - how many bits are after a period template &lt;uint8_t FractionLength&gt; class FixedPoint { public:      explicit FixedPoint(int decimal, unsigned int fraction = 0): val(0)     {         if (decimal &gt; max_dec || decimal &lt; min_dec || (decimal == min_dec &amp;&amp; fraction) || (fraction &gt;= full_fraction))         {             throw std::invalid_argument(\"It won't fit our so few bits\");         }          int8_t sign = decimal &gt; 0 ? +1 : -1;          val |= fraction;         val |= (decimal &lt;&lt; FractionLength);         val *= sign;     }      explicit FixedPoint(double v): val(0)     {         double decimal_double = 0.0;         double fraction = std::modf(v, &amp;decimal_double);          if (decimal_double &gt; max_dec || decimal_double &lt; min_dec)         {             throw std::invalid_argument(\"It won't fit our so few bits\");         }          int8_t decimal_part = static_cast&lt;int8_t&gt;(decimal_double);         int8_t sign = v &gt; 0 ? +1 : -1;         decimal_part = std::abs(decimal_part);          uint32_t fraction_decimal = std::abs(fraction)* ipow(10, FractionLength + 1);         uint8_t count = fraction_decimal \/ fraction_unit_halv;         count += count &amp; 0x01;         count &gt;&gt;= 1;          if (count &amp;&amp; sign == -1 &amp;&amp; decimal_part == min_dec_abs)         {             throw std::invalid_argument(\"It won't fit our so few bits\");         }          if (count == full_fraction)         {             decimal_part += 1;              auto decimal_part_signed = sign * decimal_part;              if (decimal_part_signed &gt; max_dec || decimal_part_signed &lt; min_dec)             {                 throw std::invalid_argument(\"It won't fit our so few bits\");             }         }         else         {             val |= count;         }          val |= (decimal_part &lt;&lt; FractionLength);          val *= sign;      }       FixedPoint operator + (const FixedPoint&amp; r) const     {         return makeFx(val + r.val);     }      FixedPoint operator - (const FixedPoint&amp; r) const     {         return makeFx(val - r.val);     }      FixedPoint operator - () const     {         return makeFx(-val);     }      FixedPoint operator * (const FixedPoint&amp; r) const     {         uint16_t temp = val * r.val;         temp &gt;&gt;= (FractionLength - 1);         uint8_t unit = temp &amp; 0x01;          return makeFx((temp &gt;&gt; 1) + unit);     }      FixedPoint operator \/ (const FixedPoint&amp; r) const     {         uint16_t left = val;         left &lt;&lt;= (FractionLength + 1);         uint8_t temp = left \/ r.val;         uint8_t unit = temp &amp; 0x01;          return makeFx((temp &gt;&gt; 1) + unit );     }      operator std::string() const     {         std::stringstream res;         uint8_t temp = val;         auto fraction = temp &amp; fraction_mask;          if (sign_mask &amp; temp)         {             res &lt;&lt; '-';              temp = ~temp + 1;             fraction = temp &amp; fraction_mask;         }          res &lt;&lt; (temp &gt;&gt; FractionLength);           if (fraction)         {             res &lt;&lt; '.' &lt;&lt; std::setw(FractionLength) &lt;&lt; fraction * fraction_unit;         }          return res.str();     }  private:      int8_t val;     static constexpr uint8_t decimal_lenght = CHAR_BIT - FractionLength;     static constexpr uint8_t max_dec = (1 &lt;&lt; (decimal_lenght - 1)) - 1;     static constexpr int8_t  min_dec_abs = (1 &lt;&lt; (decimal_lenght - 1));     static constexpr int8_t  min_dec = -min_dec_abs;     static constexpr uint32_t fraction_unit = ipow(10, FractionLength) \/ (1 &lt;&lt; FractionLength);     static constexpr uint32_t fraction_unit_halv = ipow(10, FractionLength + 1) \/ (1 &lt;&lt; (FractionLength + 1));     static constexpr uint8_t full_fraction = ipow(2, FractionLength);     static constexpr uint8_t sign_mask = 0x80;     static constexpr uint8_t fraction_mask = mask(FractionLength);     static constexpr uint8_t decimal_mask = 0xFF &amp; ~FractionLength;       explicit FixedPoint(): val(0)     {     }          static FixedPoint makeFx(int8_t v)     {         FixedPoint fp;         fp.val = v;         return fp;     } };  template &lt;uint8_t FractionLength&gt; std::ostream&amp; operator &lt;&lt; (std::ostream&amp; out, const FixedPoint&lt;FractionLength&gt;&amp; number) {     out &lt;&lt; std::string(number);      return out; }  template &lt;uint8_t FractionLength&gt; const FixedPoint&lt;FractionLength&gt; operator + (const FixedPoint&lt;FractionLength&gt;&amp; l, int r) {     return l + FixedPoint&lt;FractionLength&gt;(r); }  template &lt;uint8_t FractionLength&gt; const FixedPoint&lt;FractionLength&gt; operator + (int l, const FixedPoint&lt;FractionLength&gt;&amp; r) {     return r + FixedPoint&lt;FractionLength&gt;(l); }  template &lt;uint8_t FractionLength&gt; const FixedPoint&lt;FractionLength&gt; operator - (const FixedPoint&lt;FractionLength&gt;&amp; l, int r) {     return l - FixedPoint&lt;FractionLength&gt;(r); }  template &lt;uint8_t FractionLength&gt; const FixedPoint&lt;FractionLength&gt; operator - (int l, const FixedPoint&lt;FractionLength&gt;&amp; r) {     return r - FixedPoint&lt;FractionLength&gt;(l); }  template &lt;uint8_t FractionLength&gt; const FixedPoint&lt;FractionLength&gt; operator * (const FixedPoint&lt;FractionLength&gt;&amp; l, int r) {     return l * FixedPoint&lt;FractionLength&gt;(r); }  template &lt;uint8_t FractionLength&gt; const FixedPoint&lt;FractionLength&gt; operator * (int l, const FixedPoint&lt;FractionLength&gt;&amp; r) {     return r * FixedPoint&lt;FractionLength&gt;(l); }  template &lt;uint8_t FractionLength&gt; const FixedPoint&lt;FractionLength&gt; operator \/ (const FixedPoint&lt;FractionLength&gt;&amp; l, int r) {     return l \/ FixedPoint&lt;FractionLength&gt;(r); }  template &lt;uint8_t FractionLength&gt; const FixedPoint&lt;FractionLength&gt; operator *= (FixedPoint&lt;FractionLength&gt;&amp; l, const FixedPoint&lt;FractionLength&gt;&amp; r) {     l = l * r;     return l; }  template &lt;uint8_t FractionLength&gt; const FixedPoint&lt;FractionLength&gt; operator += (FixedPoint&lt;FractionLength&gt;&amp; l, const FixedPoint&lt;FractionLength&gt;&amp; r) {     l = l + r;     return l; }  using FixedPoint_2 = FixedPoint&lt;2&gt;; using FixedPoint_4 = FixedPoint&lt;4&gt;; <\/code><\/pre>\n<p>\u041f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p>\u0421\u0430\u043c\u0430\u044f \u0434\u043b\u0438\u043d\u043d\u0430\u044f \u0438 \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0437\u0434\u0435\u0441\u044c \u2013 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 FixedPoint(double v), \u043e\u043d \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u2013 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0447\u0442\u0435\u043d\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 FixedPoint(int decimal, unsigned int fraction = 0) \u2013 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0449\u0435, \u043d\u043e, \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c, \u043e\u043d \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u0433\u0434\u0435 \u043e\u0434\u0438\u043d \u0438\u0437 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0442\u0438\u043f\u0430 int<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u044e\u0442 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044f val, \u043d\u043e \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u2013 \u043d\u0435\u0442. \u042d\u0442\u043e \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435: \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u0440\u0435\u0437\u0430\u043b\u0438\u0441\u044c \u0438 \u0433\u0430\u0434\u0430\u0442\u044c \u043f\u043e\u0447\u0435\u043c\u0443 \u0432\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0435\u0432\u0435\u0440\u043d\u043e, \u0432 \u0442\u043e\u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0432\u0441\u044e\u0434\u0443 \u043d\u0435\u0442 \u043d\u0443\u0436\u0434\u044b, \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043a \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043d\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u0442 \u044d\u0442\u043e \u0434\u043b\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0410\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0432\u043d\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u2013 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e \u043e\u043f\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u043e\u043f\u0440\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0435 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435<\/p>\n<\/li>\n<li>\n<p>\u0421\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435 \u2013 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e, \u043d\u0435\u0442 \u0440\u0430\u0437\u043d\u0438\u0446\u044b, \u0447\u0442\u043e \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c, \u0441\u043e\u0442\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 (\u0447\u0435\u0442\u0432\u0435\u0440\u0442\u044b\u0435) \u0438\u043b\u0438 \u0446\u0435\u043b\u044b\u0435<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f makeFx \u2013 a workaround, \u0447\u0442\u043e \u0431 &#171;\u0437\u0430\u043b\u0438\u0432\u0430\u0442\u044c&#187; \u0432 \u043f\u043e\u043b\u0435 val, \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u0445<\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0442\u0432\u043e\u0440\u0438\u0442\u0441\u044f \u0432 operator * \u0438  operator \/ ? \u041f\u043e\u044f\u0441\u043d\u044f\u044e: \u0435\u0441\u043b\u0438 \u0432\u044b \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u0435 2 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0445 \u0441\u043e\u0431\u043e\u0439 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e 1\/4 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0447\u0438\u0441\u043b\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0435 \u0438\u0437 \u0441\u0435\u0431\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e 1\/16 \u2013 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0434\u0432\u0438\u043d\u0435\u043c \u0438\u0445 \u0432\u043f\u0440\u0430\u0432\u043e \u043d\u0430 2 \u0440\u0430\u0437\u0440\u044f\u0434\u0430, \u043d\u043e, \u0441\u0434\u0432\u0438\u0433\u0430 \u0442\u0430\u043a, \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0433\u0440\u0443\u0431\u043e\u0435 \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u0435 \u2013 \u0443\u0447\u0442\u0451\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0441\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0439 \u0440\u0430\u0437\u0440\u044f\u0434,\u0442\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0432 \u0447\u0438\u0441\u043b\u043e 0.10<sub>2  <\/sub>\u0434\u043e \u0441\u0434\u0432\u0438\u0433\u0430, \u0431\u0435\u0437 \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0431\u044b \u0442\u0435\u0440\u044f\u043b\u0438 \u0435\u0433\u043e \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c, \u0430 \u0442\u0430\u043a \u0434\u0435\u043b\u0430\u0435\u043c \u043f\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u044f. \u0421 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f: \u043f\u0440\u0438 \u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0432\u043e 1\/4 \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0443\u0435\u0437\u0436\u0430\u0435\u0442 \u0432\u043f\u0440\u0430\u0432\u043e 2 \u0440\u0430\u0437\u0440\u044f\u0434\u0430, \u043d\u043e \u0432 \u043a\u043e\u0434\u0435 \u044f \u0437\u0430\u0440\u043d\u0435\u0435 \u0443\u043d\u043e\u0448\u0443 \u0434\u0435\u043b\u0438\u043c\u043e\u0435 \u0432\u043b\u0435\u0432\u043e \u043d\u0430 3 \u0440\u0430\u0437\u0440\u044f\u0434\u0430 \u2013 3\u0438\u0439 \u0440\u0430\u0437\u0440\u044f\u0434  \u043e\u043f\u044f\u0442\u044c \u0436\u0435 \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u044f.<\/p>\n<p>string operator() \u0434\u0435\u043b\u0430\u0435\u0442 3 \u0432\u0435\u0449\u0438, \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u0446\u0435\u043b\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0435\u0451 \u043a\u0430\u043a \u0446\u0435\u043b\u043e\u0435, \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u0434\u0440\u043e\u0431\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0435\u0451 \u0432 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e (\u0447\u0438\u0441\u043b\u043e \u0441\u043e\u0442\u044b\u0445) \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0435\u0433\u043e \u043a\u0430\u043a \u0446\u0435\u043b\u043e\u0435, \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u2013 \u043e\u043f\u0440\u0435\u0434\u043b\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u043a\u0430, \u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0447\u0435\u0440\u0435\u0437 \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0431\u0438\u0442, \u0441\u0442\u0440\u043e\u043a\u0430 ~temp + 1 \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0443\u043d\u0430\u0440\u043d\u044b\u0439 \u043c\u0438\u043d\u0441, \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043d\u0430\u0440\u043d\u044b\u0439 \u043c\u0438\u043d\u0443\u0441 \u0441\u0442\u0440\u0430\u043d\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0434 \u0431\u0435\u0437\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u0442\u0438\u043f\u043e\u043c.<\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440\u0447\u0438\u043a, \u0433\u0434\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u043d\u0430\u0448 \u0442\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/p>\n<pre><code class=\"cpp\">template &lt;typename T&gt; T poly(T x) {     return (2*x +1)*x - 3; }  double x = 0.261799; FixedPoint_4 fx{x};  std::cout &lt;&lt; poly(x) &lt;&lt; ' ' &lt;&lt; poly(fx) &lt;&lt; std::endl;<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b:<\/p>\n<blockquote>\n<p>-2.60112 -2.6250<\/p>\n<\/blockquote>\n<p>\u041f\u043e-\u043c\u043e\u0435\u043c\u0443, \u043d\u0435\u043f\u043b\u043e\u0445\u043e, \u0434\u043b\u044f \u0442\u0438\u043f\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e &#171;\u043d\u0430 \u043a\u043e\u043b\u0435\u043d\u043a\u0435!&#187;<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0447\u0442\u043e \u0431 \u0443\u0431\u0440\u0430\u0442\u044c \u0441\u043b\u043e\u0432\u043e &#171;\u0438\u0433\u0440\u0443\u0448\u0435\u0447\u043d\u044b\u0439&#187; \u0438\u0437 \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430:<\/p>\n<ul>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u043f\u043e\u0431\u043e\u043b\u044c\u0448\u0435, \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e int32_t \u2013 \u043f\u0440\u043e\u043c\u0435\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u0432 int64_t \u043d\u0435 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0435-\u0442\u043e &#171;\u0434\u043b\u0438\u043d\u043d\u043e\u0435&#187; \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u043a\u0440\u044b\u0442\u044c \u0442\u0435\u0441\u0442\u0430\u043c\u0438<\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/831624\/\"> https:\/\/habr.com\/ru\/articles\/831624\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<p>\u0412 C++ \u043d\u0435\u0442 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e<a href=\"https:\/\/en.wikipedia.org\/wiki\/Fixed-point_arithmetic\" rel=\"noopener noreferrer nofollow\"> \u0442\u0438\u043f\u0430 \u0447\u0438\u0441\u0435\u043b \u0441 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439<\/a>, \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u0442 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0434\u043b\u044f \u043d\u0438\u0445. \u0412 \u0442\u043e\u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 (double, float) \u0447\u0430\u0441\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0442\u0432\u0435\u0442\u044c\u0442\u0435 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441: \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u0430 \u043b\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u0434 \u043d\u0438\u043c\u0438?), \u0432\u0434\u043e\u0431\u0430\u0432\u043e\u043a \u044f\u0437\u044b\u043a \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 (\u0447\u0430\u0441\u0442\u043e \u043a\u0440\u0438\u0442\u0438\u043a\u0443\u0435\u043c\u0443\u044e) \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u0430\u0440\u0438\u0444\u043c\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u043f\u043e\u0434\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044f \u043d\u0430\u0441 \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u043c \u043c\u0430\u0442. \u0447\u0430\u0441\u0442\u044c, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u0435\u043b \u0432 \u0442\u0438\u043f\u0430\u0445 uint8_t, int8_t \u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u0445 \u0430\u0440\u0438\u0444\u043c\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u0445 \u043d\u0430\u0434 \u043d\u0438\u043c\u0438. \u0418\u0442\u0430\u043a, \u0441\u043b\u043e\u0436\u0435\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 uint8_t \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e 256, \u0442\u043e \u0435\u0441\u0442\u044c 1+2 = 3, \u043d\u043e 1 + 255 = 0, \u0434\u043b\u044f int8_t  \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0432\u0432\u0435\u0441\u0442\u0438 \u0441\u043b\u0435\u0434\u0443\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u0443\u044e\u0442 \u0442\u0435\u043c \u0431\u0435\u0437\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u0447\u0438\u0441\u043b\u0430\u043c \u0438\u0437 uint8_t \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044f\u0441\u044c \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e 256 \u0434\u0430\u0434\u0443\u0442 \u043d\u043e\u043b\u044c, \u0442\u043e \u0435\u0441\u0442\u044c -1 \u0431\u0443\u0434\u0435\u043c \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442\u044c \u043a\u0430\u043a 255 (FF). \u0413\u0440\u0430\u043d\u0438\u0446\u044b \u0442\u0438\u043f\u0430 int8_t  -128&#8230;+127, \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0431\u0438\u0442 \u0432\u0441\u0435\u0433\u0434\u0430 \u0440\u0430\u0432\u0435\u043d 1. \u041f\u0440\u0438 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0438 \u0434\u0432\u0443\u0445 int8_t \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u0438\u043f\u0430 int16_t, \u0447\u0430\u0441\u0442\u043d\u043e\u0435 \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f int16_t \u043d\u0430 uint8_t \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0442\u0438\u043f uint8_t. \u0412\u0441\u0435 \u044d\u0442\u0438 \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043d\u043e\u0441\u044f\u0442 \u0430\u0431\u043e\u043b\u044e\u0442\u043d\u043e \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440, \u043d\u043e, \u043e\u043d\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0438\u0434\u0435\u0435: \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 int8_t \u0438 \u0441\u043a\u0430\u0436\u0435\u043c, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e \u043d\u0435 \u0447\u0438\u0441\u043b\u043e \u0435\u0434\u0438\u043d\u0438\u0446, \u0430 \u0441\u043a\u0430\u0436\u0435\u043c, \u0447\u0438\u0441\u043b\u043e 1\/4 (\u043f\u0440\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0441\u043b\u043e\u0432\u0430\u043c\u0438: \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u0447\u0438\u0441\u043b\u0435)? \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u0435\u043c \u044d\u0442\u0443 \u043f\u0435\u0440\u043c\u0435\u043d\u043d\u0443\u044e \u0432 \u043f\u043e\u043b\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u0438\u043c \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0430\u0440\u0438\u0444\u043c\u0438\u0442\u0438\u0447\u0435\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0439 operator string() \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430 \u0442\u0430\u043a\u0438\u0445 \u0447\u0438\u0441\u0435\u043b.  \u041d\u0438\u0436\u0435, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u044d\u0442\u043e\u0439 \u0438\u0434\u0435\u0438.<\/p>\n<pre><code class=\"cpp\">#include &lt;stdexcept&gt; #include &lt;cmath&gt; #include &lt;climits&gt; #include &lt;iostream&gt; #include &lt;sstream&gt; #include &lt;iomanip&gt;  template &lt;typename T&gt; constexpr T ipow(T num, unsigned int pow) {     return (pow &gt;= sizeof(unsigned int)*8) ? 0 :                pow == 0 ? 1 : num * ipow(num, pow-1); }  \/\/ fills and return given number of ones in the least significant bits of a byte constexpr uint8_t mask(uint8_t num) {     return num == 0 ? 0 : (mask(num - 1) &lt;&lt; 1) | 1; }  \/\/ FractionLength - how many bits are after a period template &lt;uint8_t FractionLength&gt; class FixedPoint { public:      explicit FixedPoint(int decimal, unsigned int fraction = 0): val(0)     {         if (decimal &gt; max_dec || decimal &lt; min_dec || (decimal == min_dec &amp;&amp; fraction) || (fraction &gt;= full_fraction))         {             throw std::invalid_argument(\"It won't fit our so few bits\");         }          int8_t sign = decimal &gt; 0 ? +1 : -1;          val |= fraction;         val |= (decimal &lt;&lt; FractionLength);         val *= sign;     }      explicit FixedPoint(double v): val(0)     {         double decimal_double = 0.0;         double fraction = std::modf(v, &amp;decimal_double);          if (decimal_double &gt; max_dec || decimal_double &lt; min_dec)         {             throw std::invalid_argument(\"It won't fit our so few bits\");         }          int8_t decimal_part = static_cast&lt;int8_t&gt;(decimal_double);         int8_t sign = v &gt; 0 ? +1 : -1;         decimal_part = std::abs(decimal_part);          uint32_t fraction_decimal = std::abs(fraction)* ipow(10, FractionLength + 1);         uint8_t count = fraction_decimal \/ fraction_unit_halv;         count += count &amp; 0x01;         count &gt;&gt;= 1;          if (count &amp;&amp; sign == -1 &amp;&amp; decimal_part == min_dec_abs)         {             throw std::invalid_argument(\"It won't fit our so few bits\");         }          if (count == full_fraction)         {             decimal_part += 1;              auto decimal_part_signed = sign * decimal_part;              if (decimal_part_signed &gt; max_dec || decimal_part_signed &lt; min_dec)             {                 throw std::invalid_argument(\"It won't fit our so few bits\");             }         }         else         {             val |= count;         }          val |= (decimal_part &lt;&lt; FractionLength);          val *= sign;      }       FixedPoint operator + (const FixedPoint&amp; r) const     {         return makeFx(val + r.val);     }      FixedPoint operator - (const FixedPoint&amp; r) const     {         return makeFx(val - r.val);     }      FixedPoint operator - () const     {         return makeFx(-val);     }      FixedPoint operator * (const FixedPoint&amp; r) const     {         uint16_t temp = val * r.val;         temp &gt;&gt;= (FractionLength - 1);         uint8_t unit = temp &amp; 0x01;          return makeFx((temp &gt;&gt; 1) + unit);     }      FixedPoint operator \/ (const FixedPoint&amp; r) const     {         uint16_t left = val;         left &lt;&lt;= (FractionLength + 1);         uint8_t temp = left \/ r.val;         uint8_t unit = temp &amp; 0x01;          return makeFx((temp &gt;&gt; 1) + unit );     }      operator std::string() const     {         std::stringstream res;         uint8_t temp = val;         auto fraction = temp &amp; fraction_mask;          if (sign_mask &amp; temp)         {             res &lt;&lt; '-';              temp = ~temp + 1;             fraction = temp &amp; fraction_mask;         }          res &lt;&lt; (temp &gt;&gt; FractionLength);           if (fraction)         {             res &lt;&lt; '.' &lt;&lt; std::setw(FractionLength) &lt;&lt; fraction * fraction_unit;         }          return res.str();     }  private:      int8_t val;     static constexpr uint8_t decimal_lenght = CHAR_BIT - FractionLength;     static constexpr uint8_t max_dec = (1 &lt;&lt; (decimal_lenght - 1)) - 1;     static constexpr int8_t  min_dec_abs = (1 &lt;&lt; (decimal_lenght - 1));     static constexpr int8_t  min_dec = -min_dec_abs;     static constexpr uint32_t fraction_unit = ipow(10, FractionLength) \/ (1 &lt;&lt; FractionLength);     static constexpr uint32_t fraction_unit_halv = ipow(10, FractionLength + 1) \/ (1 &lt;&lt; (FractionLength + 1));     static constexpr uint8_t full_fraction = ipow(2, FractionLength);     static constexpr uint8_t sign_mask = 0x80;     static constexpr uint8_t fraction_mask = mask(FractionLength);     static constexpr uint8_t decimal_mask = 0xFF &amp; ~FractionLength;       explicit FixedPoint(): val(0)     {     }          static FixedPoint makeFx(int8_t v)     {         FixedPoint fp;         fp.val = v;         return fp;     } };  template &lt;uint8_t FractionLength&gt; std::ostream&amp; operator &lt;&lt; (std::ostream&amp; out, const FixedPoint&lt;FractionLength&gt;&amp; number) {     out &lt;&lt; std::string(number);      return out; }  template &lt;uint8_t FractionLength&gt; const FixedPoint&lt;FractionLength&gt; operator + (const FixedPoint&lt;FractionLength&gt;&amp; l, int r) {     return l + FixedPoint&lt;FractionLength&gt;(r); }  template &lt;uint8_t FractionLength&gt; const FixedPoint&lt;FractionLength&gt; operator + (int l, const FixedPoint&lt;FractionLength&gt;&amp; r) {     return r + FixedPoint&lt;FractionLength&gt;(l); }  template &lt;uint8_t FractionLength&gt; const FixedPoint&lt;FractionLength&gt; operator - (const FixedPoint&lt;FractionLength&gt;&amp; l, int r) {     return l - FixedPoint&lt;FractionLength&gt;(r); }  template &lt;uint8_t FractionLength&gt; const FixedPoint&lt;FractionLength&gt; operator - (int l, const FixedPoint&lt;FractionLength&gt;&amp; r) {     return r - FixedPoint&lt;FractionLength&gt;(l); }  template &lt;uint8_t FractionLength&gt; const FixedPoint&lt;FractionLength&gt; operator * (const FixedPoint&lt;FractionLength&gt;&amp; l, int r) {     return l * FixedPoint&lt;FractionLength&gt;(r); }  template &lt;uint8_t FractionLength&gt; const FixedPoint&lt;FractionLength&gt; operator * (int l, const FixedPoint&lt;FractionLength&gt;&amp; r) {     return r * FixedPoint&lt;FractionLength&gt;(l); }  template &lt;uint8_t FractionLength&gt; const FixedPoint&lt;FractionLength&gt; operator \/ (const FixedPoint&lt;FractionLength&gt;&amp; l, int r) {     return l \/ FixedPoint&lt;FractionLength&gt;(r); }  template &lt;uint8_t FractionLength&gt; const FixedPoint&lt;FractionLength&gt; operator *= (FixedPoint&lt;FractionLength&gt;&amp; l, const FixedPoint&lt;FractionLength&gt;&amp; r) {     l = l * r;     return l; }  template &lt;uint8_t FractionLength&gt; const FixedPoint&lt;FractionLength&gt; operator += (FixedPoint&lt;FractionLength&gt;&amp; l, const FixedPoint&lt;FractionLength&gt;&amp; r) {     l = l + r;     return l; }  using FixedPoint_2 = FixedPoint&lt;2&gt;; using FixedPoint_4 = FixedPoint&lt;4&gt;; <\/code><\/pre>\n<p>\u041f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p>\u0421\u0430\u043c\u0430\u044f \u0434\u043b\u0438\u043d\u043d\u0430\u044f \u0438 \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0437\u0434\u0435\u0441\u044c \u2013 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 FixedPoint(double v), \u043e\u043d \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u2013 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0447\u0442\u0435\u043d\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 FixedPoint(int decimal, unsigned int fraction = 0) \u2013 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0449\u0435, \u043d\u043e, \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c, \u043e\u043d \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u0433\u0434\u0435 \u043e\u0434\u0438\u043d \u0438\u0437 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0442\u0438\u043f\u0430 int<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u044e\u0442 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044f val, \u043d\u043e \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u2013 \u043d\u0435\u0442. \u042d\u0442\u043e \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435: \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u0440\u0435\u0437\u0430\u043b\u0438\u0441\u044c \u0438 \u0433\u0430\u0434\u0430\u0442\u044c \u043f\u043e\u0447\u0435\u043c\u0443 \u0432\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0435\u0432\u0435\u0440\u043d\u043e, \u0432 \u0442\u043e\u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0432\u0441\u044e\u0434\u0443 \u043d\u0435\u0442 \u043d\u0443\u0436\u0434\u044b, \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043a \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043d\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u0442 \u044d\u0442\u043e \u0434\u043b\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0410\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0432\u043d\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u2013 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e \u043e\u043f\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u043e\u043f\u0440\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0435 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435<\/p>\n<\/li>\n<li>\n<p>\u0421\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435 \u2013 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e, \u043d\u0435\u0442 \u0440\u0430\u0437\u043d\u0438\u0446\u044b, \u0447\u0442\u043e \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c, \u0441\u043e\u0442\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 (\u0447\u0435\u0442\u0432\u0435\u0440\u0442\u044b\u0435) \u0438\u043b\u0438 \u0446\u0435\u043b\u044b\u0435<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f makeFx \u2013 a workaround, \u0447\u0442\u043e \u0431 &#171;\u0437\u0430\u043b\u0438\u0432\u0430\u0442\u044c&#187; \u0432 \u043f\u043e\u043b\u0435 val, \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u0445<\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0442\u0432\u043e\u0440\u0438\u0442\u0441\u044f \u0432 operator * \u0438  operator \/ ? \u041f\u043e\u044f\u0441\u043d\u044f\u044e: \u0435\u0441\u043b\u0438 \u0432\u044b \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u0435 2 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0445 \u0441\u043e\u0431\u043e\u0439 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e 1\/4 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0447\u0438\u0441\u043b\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0435 \u0438\u0437 \u0441\u0435\u0431\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e 1\/16 \u2013 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0434\u0432\u0438\u043d\u0435\u043c \u0438\u0445 \u0432\u043f\u0440\u0430\u0432\u043e \u043d\u0430 2 \u0440\u0430\u0437\u0440\u044f\u0434\u0430, \u043d\u043e, \u0441\u0434\u0432\u0438\u0433\u0430 \u0442\u0430\u043a, \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0433\u0440\u0443\u0431\u043e\u0435 \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u0435 \u2013 \u0443\u0447\u0442\u0451\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0441\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0439 \u0440\u0430\u0437\u0440\u044f\u0434,\u0442\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0432 \u0447\u0438\u0441\u043b\u043e 0.10<sub>2  <\/sub>\u0434\u043e \u0441\u0434\u0432\u0438\u0433\u0430, \u0431\u0435\u0437 \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0431\u044b \u0442\u0435\u0440\u044f\u043b\u0438 \u0435\u0433\u043e \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c, \u0430 \u0442\u0430\u043a \u0434\u0435\u043b\u0430\u0435\u043c \u043f\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u044f. \u0421 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f: \u043f\u0440\u0438 \u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0432\u043e 1\/4 \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0443\u0435\u0437\u0436\u0430\u0435\u0442 \u0432\u043f\u0440\u0430\u0432\u043e 2 \u0440\u0430\u0437\u0440\u044f\u0434\u0430, \u043d\u043e \u0432 \u043a\u043e\u0434\u0435 \u044f \u0437\u0430\u0440\u043d\u0435\u0435 \u0443\u043d\u043e\u0448\u0443 \u0434\u0435\u043b\u0438\u043c\u043e\u0435 \u0432\u043b\u0435\u0432\u043e \u043d\u0430 3 \u0440\u0430\u0437\u0440\u044f\u0434\u0430 \u2013 3\u0438\u0439 \u0440\u0430\u0437\u0440\u044f\u0434  \u043e\u043f\u044f\u0442\u044c \u0436\u0435 \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u044f.<\/p>\n<p>string operator() \u0434\u0435\u043b\u0430\u0435\u0442 3 \u0432\u0435\u0449\u0438, \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u0446\u0435\u043b\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0435\u0451 \u043a\u0430\u043a \u0446\u0435\u043b\u043e\u0435, \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u0434\u0440\u043e\u0431\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0435\u0451 \u0432 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e (\u0447\u0438\u0441\u043b\u043e \u0441\u043e\u0442\u044b\u0445) \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0435\u0433\u043e \u043a\u0430\u043a \u0446\u0435\u043b\u043e\u0435, \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u2013 \u043e\u043f\u0440\u0435\u0434\u043b\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u043a\u0430, \u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0447\u0435\u0440\u0435\u0437 \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0431\u0438\u0442, \u0441\u0442\u0440\u043e\u043a\u0430 ~temp + 1 \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0443\u043d\u0430\u0440\u043d\u044b\u0439 \u043c\u0438\u043d\u0441, \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043d\u0430\u0440\u043d\u044b\u0439 \u043c\u0438\u043d\u0443\u0441 \u0441\u0442\u0440\u0430\u043d\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0434 \u0431\u0435\u0437\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u0442\u0438\u043f\u043e\u043c.<\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0443<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-427466","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/427466","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=427466"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/427466\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=427466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=427466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=427466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}