{"id":378242,"date":"2024-06-07T09:00:45","date_gmt":"2024-06-07T09:00:45","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=378242"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=378242","title":{"rendered":"<span>\u0410\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0430 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a<\/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\/r\/w1560\/getpro\/habr\/upload_files\/d01\/186\/5ad\/d011865ad1a8cea04f3febab4243a202.png\" width=\"1400\" height=\"806\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d01\/186\/5ad\/d011865ad1a8cea04f3febab4243a202.png\"\/><\/figure>\n<p>\u0427\u0438\u0441\u043b\u0430 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 (\u043e\u0434\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u0438\u043b\u0438 \u0434\u0432\u043e\u0439\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438) \u043f\u0435\u0447\u0430\u043b\u044c\u043d\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0437\u0430 \u043d\u0435\u043b\u0435\u043f\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/043\/e92\/f5a\/043e92f5a1c114357a2632895600b49a.png\" alt=\"\u041e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442: 0.3\" title=\"\u041e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442: 0.3\" width=\"311\" height=\"75\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/043\/e92\/f5a\/043e92f5a1c114357a2632895600b49a.png\"\/><\/p>\n<div><figcaption>\u041e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442: 0.3<\/figcaption><\/div>\n<\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0d0\/f0d\/eab\/0d0f0deab0004608cb9b241215333741.png\" alt=\"\u041e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442: 0.2\" title=\"\u041e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442: 0.2\" width=\"311\" height=\"75\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0d0\/f0d\/eab\/0d0f0deab0004608cb9b241215333741.png\"\/><\/p>\n<div><figcaption>\u041e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442: 0.2<\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0438 \u0434\u0430\u0436\u0435 \u043e\u0446\u0435\u043d\u043e\u043a \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0442\u0430\u043a\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439, <a href=\"https:\/\/medium.com\/@ellenaua\/floating-point-errors-in-javascript-node-js-21aadd897bf8\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f JavaScript, \u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0432\u0435\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 <a href=\"https:\/\/ieeexplore.ieee.org\/document\/8766229\" rel=\"noopener noreferrer nofollow\">IEEE-754<\/a> (\u0442.\u0435. \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f).<\/p>\n<h2>\u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442?<\/h2>\n<p>\u0420\u0435\u0441\u0443\u0440\u0441\u044b \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0435\u0442 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u0431\u043e\u043b\u044c\u0448\u0435 255 \u0438\u043b\u0438 \u043c\u0435\u043d\u044c\u0448\u0435 0 \u0432 \u043e\u0434\u043d\u043e\u043c \u0431\u0430\u0439\u0442\u0435. \u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f [-128; 127]. \u0412\u0435\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u044b \u043f\u043e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438. \u0426\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u0432\u044b\u0445\u043e\u0434\u044f\u0442 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b, \u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u0430 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u0432\u044b\u0440\u043e\u0436\u0434\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u043c\u0435\u0440\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"go\">import ( \"fmt\" )  func main() { fmt.Println(float32(16777215.0) == float32(16777216.0)) \/\/ false fmt.Println(float32(16777216.0) == float32(16777217.0)) \/\/ true fmt.Println(float32(16777216.0)) \/\/ 1.6777216e+07 fmt.Println(float32(16777217.0)) \/\/ 1.6777216e+07 }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0434\u0430\u0436\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0432\u043e float32, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0442\u043c\u0435\u0442\u043a\u0438. \u0422\u0438\u043f float64 \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0448\u0438\u0440\u043e\u043a\u0438\u0439 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b, \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u044b\u0445 \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a. \u041d\u043e \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u0430 \u043e\u0442\u043c\u0435\u0442\u043a\u0430? \u041d\u0443, 16 777 216 = 2\u00b2\u00b3 \u00d7 2. \u0410 \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u0430 \u0447\u0438\u0441\u043b\u0430 float32 \u0438\u043c\u0435\u0435\u0442 \u0434\u043b\u0438\u043d\u0443 23 \u0431\u0438\u0442\u0430. \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0438 \u044d\u0442\u043e \u0442\u0430 \u043e\u0442\u043c\u0435\u0442\u043a\u0430, \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0432\u044b\u0440\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f? \u041b\u0435\u0433\u043a\u043e \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"go\">for i := float32(0.0); i &lt;= float32(16777216.0); i += float32(1.0) { if i == 16777215.0 { fmt.Printin(\"halt\") \/\/ breakpoint here }  if i == i+float32(1.0) { fmt.Println(i) \/\/ breakpoint here } }<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0431\u043b\u043e\u043a \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442, \u043f\u043e\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043d\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0435\u0442 16 777 215. \u041a\u043e\u0433\u0434\u0430 \u043e\u043d\u0430 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442 16 777 216, \u0442\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441 16 777 216 + 1, \u0438 \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u0432\u043e float32. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u0434 \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430. \u041f\u043e \u0442\u043e\u0439 \u0436\u0435 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0435\u043b\u044c\u0437\u044f, \u0438 \u0446\u0438\u043a\u043b \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0442\u043e\u0442 \u0436\u0435 \u0432\u044b\u0432\u043e\u0434 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/664\/8b6\/4c4\/6648b64c48c0f4efaa5ba6261d1d762a.png\" width=\"248\" height=\"89\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/664\/8b6\/4c4\/6648b64c48c0f4efaa5ba6261d1d762a.png\"\/><\/figure>\n<p>\u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0438 \u0432 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438. \u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442:<\/p>\n<pre><code class=\"go\">for i := float32(0.0); i >= -float32(16777216.0); i -= float32(1.0) { if i == -16777215.0 { fmt.Printin(\"halt\") \/\/ breakpoint here }  if i == i-float32(1.0) { fmt.Println(i) \/\/ breakpoint here } }<\/code><\/pre>\n<p>\u041c\u0430\u043d\u0442\u0438\u0441\u0441\u0430 \u0447\u0438\u0441\u043b\u0430 float64 \u0431\u043e\u043b\u044c\u0448\u0435 (52 \u0431\u0438\u0442\u0430 \u0432 \u0434\u043b\u0438\u043d\u0443). \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 [-2\u2075\u00b3; 2\u2075\u00b3]. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d, \u043d\u043e \u0434\u0430, \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e \u0438 \u0437\u0434\u0435\u0441\u044c. \u0412\u043e\u0442 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"go\">package main  import ( \"fmt\" \"math\" )  func main() { fmt.Println(math.Pow(2, 53) == math.Pow(2, 53)-1) \/\/ false fmt.Println(math.Pow(2, 53) == math.Pow(2, 53)+1) \/\/ true }<\/code><\/pre>\n<h2>\u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e?<\/h2>\n<p>&#8212; \u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c. \u042f \u0441\u043b\u044b\u0448\u0430\u043b, \u0432\u044b \u0443\u043c\u0435\u0435\u0442\u0435 \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u0443\u043c\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c. \u0418\u0442\u0430\u043a, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0443\u0434\u0435\u0442 14 * 17?<br \/>&#8212; 230<br \/>&#8212; \u041d\u043e \u044d\u0442\u043e \u043d\u0435\u0432\u0435\u0440\u043d\u043e!<br \/>&#8212; \u0417\u0430\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u043e.<\/p>\n<h2>\u041a\u0430\u043a \u0441 \u044d\u0442\u0438\u043c \u0436\u0438\u0442\u044c<\/h2>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u0430 \u0441 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439, \u0442\u0438\u043f <a href=\"https:\/\/github.com\/shopspring\/decimal\" rel=\"noopener noreferrer nofollow\">Decimal<\/a> \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u0435 (\u0435\u0441\u043b\u0438 \u0432\u044b \u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0435\u0442\u0435, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0446\u0438\u0444\u0440 \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0447\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u0432\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435). \u0415\u0441\u043b\u0438 \u0432 \u0432\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u043c\u0435\u0442\u044c \u0434\u0435\u043b\u043e \u0441 \u0434\u0435\u043d\u0435\u0436\u043d\u044b\u043c\u0438 \u0435\u0434\u0438\u043d\u0438\u0446\u0430\u043c\u0438, \u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c <a href=\"https:\/\/github.com\/Rhymond\/go-money\" rel=\"noopener noreferrer nofollow\">\u0448\u0430\u0431\u043b\u043e\u043d \u041c\u0430\u0440\u0442\u0438\u043d\u0430 \u0424\u0430\u0443\u043b\u0435\u0440\u0430 \u0434\u043b\u044f \u0432\u0430\u043b\u044e\u0442\u043d\u044b\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d<\/a>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u0436\u0435\u043b\u0435\u0437\u043d\u043e \u043d\u0430\u0434\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c float \u0438 \u0432\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a\u043e\u0432\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u044f, \u0443 \u043c\u0435\u043d\u044f \u0435\u0441\u0442\u044c \u0434\u043b\u044f \u0432\u0430\u0441 \u0445\u0438\u0442\u0440\u043e\u0443\u043c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<h2>\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438<\/h2>\n<p>\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u0445 \u043d\u0430\u0434 \u0434\u0432\u0443\u043c\u044f \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439:<\/p>\n<ul>\n<li>\n<p>\u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u044b \u0432\u044b\u0448\u0435\u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u043c\u0438 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430\u043c\u0438 ([-2\u00b2\u2074, 2\u00b2\u2074] \u0434\u043b\u044f float32, [-2\u2075\u00b3; 2\u2075\u00b3] \u0434\u043b\u044f float64); \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445;<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b (\u0442\u0435 \u0436\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430);<\/p>\n<\/li>\n<li>\n<p>\u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b (\u0442\u0435 \u0436\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430);<\/p>\n<\/li>\n<li>\n<p>\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b (\u0442\u0435 \u0436\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430);<\/p>\n<\/li>\n<li>\n<p>\u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043b\u044e\u0431\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 (\u0446\u0435\u043b\u043e\u0433\u043e \u0438\u043b\u0438 \u0434\u0440\u043e\u0431\u043d\u043e\u0433\u043e) \u043d\u0430 10 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 n, \u0433\u0434\u0435 n \u2265 0, n \u2014 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e;<\/p>\n<\/li>\n<li>\n<p>\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043b\u044e\u0431\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 (\u0446\u0435\u043b\u043e\u0433\u043e \u0438\u043b\u0438 \u0434\u0440\u043e\u0431\u043d\u043e\u0433\u043e) \u043d\u0430 10 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 n, \u0433\u0434\u0435 n \u2265 0, n \u2014 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e;<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0433\u043e, \u0435\u0441\u043b\u0438 \u0431\u0443\u0434\u0435\u0442\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0432\u044b\u0448\u0435\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u0447\u0435\u0440\u0435\u0437 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f.<\/p>\n<h2>\u0422\u0435\u043e\u0440\u0438\u044f<\/h2>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u0442\u044c 3,8 \u043a 2,56. \u0415\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044f\u0437\u044b\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0432\u0435\u0440\u043d\u0443\u043b \u0431\u044b 6,359999999999999. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0448\u043a\u043e\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d4f\/b7f\/7ef\/d4fb7f7ef73d36a6a9d756076f76d5bb.png\" width=\"725\" height=\"84\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d4f\/b7f\/7ef\/d4fb7f7ef73d36a6a9d756076f76d5bb.png\"\/><\/figure>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0434\u0432\u0430 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 \u0438 \u0434\u0435\u043b\u0438\u043c \u0438\u0445 \u043d\u0430 10\u00b2. \u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e \u0438 \u043a \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u044e. \u041e\u0434\u043d\u0430\u043a\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c \u043d\u0438\u0436\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e85\/c39\/7ec\/e85c397ec01912e5e30e706f9d020c77.png\" width=\"791\" height=\"164\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e85\/c39\/7ec\/e85c397ec01912e5e30e706f9d020c77.png\"\/><\/figure>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e, \u0432\u0441\u0435 \u0434\u0435\u043b\u043e \u0432 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0438 \u0434\u043b\u0438\u043d\u044b \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0447\u0438\u0441\u043b\u0430 \u0438 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0438 \u0435\u0435 \u043d\u0430 10 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u044d\u0442\u043e\u0439 \u0434\u043b\u0438\u043d\u044b. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0446\u0435\u043b\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u0432\u0435\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445. \u0412 \u043a\u043e\u043d\u0446\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u0440\u043e\u0431\u043d\u044b\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 10 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430.<\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u044f \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u2014 \u044d\u0442\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0440\u0435\u0434\u0438 \u043e\u0431\u043e\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u043d\u0434\u043e\u0432. \u0412 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0438 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u2014 \u044d\u0442\u043e \u0441\u0443\u043c\u043c\u0430 \u0434\u043b\u0438\u043d \u0434\u0440\u043e\u0431\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u043e\u0431\u043e\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u043d\u0434\u043e\u0432. \u041d\u043e \u0441 \u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0432\u0441\u0451 \u043d\u0435 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e. \u0415\u0441\u0442\u044c \u0442\u0440\u0438 \u0441\u043b\u0443\u0447\u0430\u044f:<\/p>\n<ul>\n<li>\n<p>\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0434\u043b\u0438\u043d\u0443 \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u0447\u0435\u043c \u0437\u043d\u0430\u043c\u0435\u043d\u0430\u0442\u0435\u043b\u044c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bbe\/79b\/441\/bbe79b441c7895f21ddded4e1b505003.png\" width=\"808\" height=\"151\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bbe\/79b\/441\/bbe79b441c7895f21ddded4e1b505003.png\"\/><\/figure>\n<\/li>\n<li>\n<p>\u0437\u043d\u0430\u043c\u0435\u043d\u0430\u0442\u0435\u043b\u044c \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0434\u043b\u0438\u043d\u0443 \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u0447\u0435\u043c \u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7ad\/4a3\/9b0\/7ad4a39b0128dd7dc733300f03eaeff2.png\" width=\"836\" height=\"124\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7ad\/4a3\/9b0\/7ad4a39b0128dd7dc733300f03eaeff2.png\"\/><\/figure>\n<\/li>\n<li>\n<p>\u0434\u0440\u043e\u0431\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 \u043e\u0431\u043e\u0438\u0445 \u0447\u0438\u0441\u0435\u043b \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b \u043f\u043e \u0434\u043b\u0438\u043d\u0435:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f08\/fd7\/fe5\/f08fd7fe5b605291fd4b37509b02f0b1.png\" width=\"356\" height=\"91\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f08\/fd7\/fe5\/f08fd7fe5b605291fd4b37509b02f0b1.png\"\/><\/figure>\n<\/li>\n<\/ul>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0434\u0435\u043b\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0412 \u0442\u0440\u0435\u0442\u044c\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u043a\u0430\u043a \u0435\u0441\u0442\u044c.<\/p>\n<h2>\u041d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u043d\u044b \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/h2>\n<p>\u041a\u0430\u043a \u0432\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u043a\u0430\u0436\u0434\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0434\u043b\u0438\u043d\u044b \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u043d\u0434\u0430. \u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0443\u043c, \u2014 \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 \u043b\u043e\u0431, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 \u0438\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442:<\/p>\n<pre><code class=\"go\">import ( \"strconv\" \"strings\" )  func GetPartsLength(number float64) (int, int) { numStr := strconv.FormatFloat(number, 'f', -1, 64) numStr = strings.TrimPrefix(numStr, \"-\") parts := strings.Split(numStr, \".\")  if len(parts) > 1 { return len(parts[0]), len(parts[1]) }  if len(parts) == 1 { return len(parts[0]), 0 }  return -1, -1 }<\/code><\/pre>\n<p>\u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u043b\u0438\u043d\u0443 \u0446\u0435\u043b\u043e\u0439 \u0438 \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0435\u0439 \u0447\u0438\u0441\u043b\u0430. \u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u044d\u0442\u043e \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c, \u043d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u043c\u0435\u0440\u0438\u043c \u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c:<\/p>\n<pre><code class=\"go\">func BenchmarkGetPartsLength(b *testing.B) { for i := 0; i &lt; b.N; i++ { safecomp.GetPartsLength(-19367.5889) } }<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0432\u043e\u043e\u0434\u0443\u0448\u0435\u0432\u043b\u044f\u044e\u0449\u0438\u0439:<\/p>\n<pre><code>Running tool: \/usr\/bin\/go test -benchmem -run=A$ \\ -bench ABenchmarkGetPartsLength$ ieee-754\/safecomp  goos: linux goarch: amd64 pkg: ieee-754\/safecomp cpu: AMD Ryzen 5 5600H with Radeon Graphics  BenchmarkGetPartsLength-12  7736520   263.0 ns\/op  72 B\/op   3 allocs\/op  PASS ok ieee-754\/safecomp 2.196s<\/code><\/pre>\n<p>\u0421\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0432\u0435\u0441\u044c\u043c\u0430 \u0437\u0430\u0442\u0440\u0430\u0442\u043d\u044b \u0432 \u043f\u043b\u0430\u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0426\u041f \u0438 \u041e\u0417\u0423. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043e\u043d\u0438 \u0447\u0430\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u0414\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e strconv.FormatFloat \u0434\u043e\u043b\u0436\u0435\u043d \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0437\u043d\u0430\u0442\u044c, \u0433\u0434\u0435 \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0442\u043e\u0447\u043a\u0443 \u0432 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0447\u0438\u0441\u043b\u0430 \u0442\u0438\u043f\u0430 float. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0421\u0442\u044d\u043a \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f34\/153\/925\/f341539257b6a0a380e79702379dde2c.png\" width=\"775\" height=\"523\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f34\/153\/925\/f341539257b6a0a380e79702379dde2c.png\"\/><\/figure>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f ryuFtoaShortest \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c Ry\u016b. \u041e\u043d\u0430 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0442\u0438\u043f\u0430 decimalSlice:<\/p>\n<pre><code class=\"go\">type decimalslice struct { d      []byte nd, dp int neg    bool }<\/code><\/pre>\n<p>nd \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u00ab\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0446\u0438\u0444\u0440\u00bb. \u041e\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442 \u043e\u0431\u0449\u0443\u044e \u0434\u043b\u0438\u043d\u0443 \u0447\u0438\u0441\u043b\u0430, \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f \u0437\u043d\u0430\u043a \u0438 \u0442\u043e\u0447\u043a\u0443. dp \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u00ab\u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c\u00bb. \u041e\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442 \u0434\u043b\u0438\u043d\u0443 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u0438\u043d\u0430 \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0440\u0430\u0432\u043d\u0430 nd &#8212; dp.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u043d\u0430\u0448\u0435\u0439 \u0446\u0435\u043b\u0438. \u041e\u043d\u0438 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \/usr\/lib\/go\/src\/strconv. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u0443\u0442\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438, \u0432\u0435\u0440\u0441\u0438\u0438 \u044f\u0437\u044b\u043a\u0430, \u041e\u0421 \u0438 \u0442. \u0434. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b \u0438\u0437 \u043f\u0430\u043a\u0435\u0442\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u044b\u043b\u043e \u0431\u044b \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0443\u0442\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c-\u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e. \u0412\u043e\u0442 \u043f\u043e\u0447\u0435\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0432\u0435\u0441\u044c \u043f\u0430\u043a\u0435\u0442 \u0432 \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442. \u0418 \u0432\u043e\u0442 \u043a \u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u043b\u043e:<\/p>\n<pre><code>[zergon321@astroemeria ieee-754]$ go run main.go package command-line-arguments   imports ieee-754\/alt   alt\/bytealg.go:10:8: use of internal package internal\/bytealg not allowed<\/code><\/pre>\n<p>\u0423\u043f\u0441. \u0427\u0442\u043e \u0436, \u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0434\u0430\u043b\u0438\u043b \u0444\u0430\u0439\u043b bytealg.go \u0438 \u0432\u0441\u0451, \u0447\u0442\u043e \u043e\u0442 \u043d\u0435\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0435\u043b\u043e. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0444\u0443\u043d\u043a\u0446\u0438\u044f genericFtoa \u043a \u0442\u0430\u043a\u043e\u0432\u043e\u043c\u0443 \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u043b\u0430\u0441\u044c. \u0412\u0441\u0435 \u043c\u043e\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u0440\u0438\u0432\u0435\u043b\u0438 \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e GetPartsLength, \u0447\u0442\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435:<\/p>\n<pre><code class=\"go\">package alt  import \"math\"  func GetPartsLength(val float64, fmt byte, prec, bitSize int) (int, int) { var bits uint64 var flt *floatInfo switch bitSize { case 32: bits = uint64(math.Float32bits(float32(val))) flt = &amp;float32info case 64: bits = math.Float64bits(val) flt = &amp;float64info default: panic(\"strconv: illegal AppendFloat\/FormatFloat bitSize\") }  exp := int(bits>>flt.mantbits) &amp; (1&lt;&lt;flt.expbits - 1) mant := bits &amp; (uint64(1)&lt;&lt;flt.mantbits - 1)  switch exp { case 1&lt;&lt;flt.expbits - 1: \/\/ Inf, NaN return -1, -1  case 0: \/\/ denormalized exp++  default: \/\/ add implicit top bit mant |= uint64(1) &lt;&lt; flt.mantbits } exp += flt.bias  var digs decimalSlice \/\/ Negative precision means \"only as much as needed to be exact.\" shortest := prec &lt; 0 if shortest { \/\/ Use Ryu algorithm. var buf [32]byte digs.d = buf[:] ryuFtoaShortest(&amp;digs, mant, exp-int(flt.mantbits), flt) } else if fmt != 'f' { \/\/ Fixed number of digits. digits := prec switch fmt { case 'e', 'E': digits++ case 'g', 'G': if prec == 0 { prec = 1 } digits = prec default: \/\/ Invalid mode. digits = 1 } var buf [24]byte if bitSize == 32 &amp;&amp; digits &lt;= 9 { digs.d = buf[:] ryuFtoaFixed32(&amp;digs, uint32(mant), exp-int(flt.mantbits), digits) } else if digits &lt;= 18 { digs.d = buf[:] ryuFtoaFixed64(&amp;digs, mant, exp-int(flt.mantbits), digits) } }  return digs.dp, digs.nd - digs.dp }<\/code><\/pre>\n<p>\u042d\u0442\u043e \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e, \u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435:<\/p>\n<pre><code>Running tool: \/usr\/bin\/go test -benchmem -run=A$ \\ -bench ABenchmarkGetPartsLength$ ieee-754\/test  goos: linux goarch: amd64 pkg: ieee-754\/test cpu: AMD Ryzen 5 5600H with Radeon Graphics  BenchmarkGetPartsLength-12   25748916   47.21 ns\/op   0 B\/op   0 allocs\/op  PASS ok ieee-754\/test 1.266s<\/code><\/pre>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438.<\/p>\n<pre><code class=\"go\">\/\/ \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f. func Sum(a, b float64) float64 { aFracLen := alt.GetPartsLength(a, 'f', -1, 64) bFracLen := alt.GetPartsLength(b, 'f', -1, 64)  aModifier := math.Pow10(aFracLen) bModifier := math.Pow10(bFracLen) modifier := math.Max(aModifier, bModifier)  a *= modifier b *= modifier  return (a + b) \/ modifier }<\/code><\/pre>\n<pre><code class=\"go\">\/\/ \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u044f. func Sub(a, b float64) float64 { aFracLen := alt.GetPartsLength(a, 'f', -1, 64) bFracLen := alt.GetPartsLength(b, 'f', -1, 64)  aModifier := math.Pow10(aFracLen) bModifier := math.Pow10(bFracLen)  modifier := math.Max(aModifier, bModifier) a *= modifier b *= modifier  return (a - b) \/ modifier }<\/code><\/pre>\n<pre><code class=\"go\">\/\/ \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f. func Mul(a, b float64) float64 { aFracLen := alt.GetPartsLength(a, 'f', -1, 64) bFracLen := alt.GetPartsLength(b, 'f', -1, 64)  aModifier := math.Pow10(aFracLen) bModifier := math.Pow10(bFracLen)  modifier := aModifier * bModifier a *= aModifier b *= bModifier  return a * b \/ modifier }<\/code><\/pre>\n<pre><code class=\"go\">\/\/ \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u0435\u043b\u0435\u043d\u0438\u044f. func Div(a, b float64) float64 { aFracLen := alt.GetPartsLength(a, 'f', -1, 64) bFracLen := alt.GetPartsLength(b, 'f', -1, 64)  aModifier := math.Pow10(aFracLen) bModifier := math.Pow10(bFracLen)  minModifier := math.Min(aModifier, bModifier) maxModifier := math.Max(aModifier, bModifier) modifier := maxModifier \/ minModifier  a *= aModifier b *= bModifier result := a \/ b  if aModifier > bModifier { return result \/ modifier }  if bModifier > aModifier { return result * modifier }  return result }<\/code><\/pre>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u043f\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u044b\u0447\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0441 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0437\u0430\u043f\u044f\u0442\u043e\u0439 \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0443\u044e:<\/p>\n<pre><code class=\"go\">func BenchmarkSafeMulFloat64(b *testing.B) { for i := 0; i &lt; b.N; i++ { safecomp.Mul(2090.5, 8.61) } }  func BenchmarkRegularMulFloat64(b *testing.B) { for i := 0; i &lt; b.N; i++ { _ = 2090.5 * 8.61 } }  func BenchmarkMulDecimal(b *testing.B) { x := decimal.NewFromFloat(2090.5) \u0443 := decimal.NewFromFloat(8.61)  for i := 0; i &lt; b.N; i++ { x.Mul(y) } }<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code>Running tool: \/usr\/bin\/go test -benchmem -run=A$ \\ -bench \u043b(BenchmarkSafeMulFloat64|BenchmarkRegularMulFloat64| \\ BenchmarkMulDecimal)$ github.com\/zergon321\/safecomp  goos: linux goarch: amd64 pkg: github.com\/zergon321\/safecomp cpu: AMD Ryzen 5 5600H with Radeon Graphics  BenchmarkSafeMulFloat64-12   16182450    74.24 ns\/op   0 B\/op   0 allocs\/op BenchmarkRegularMulFloat64-12 1000000000  0.2418 ns\/op  0 B\/op  0 allocs\/op BenchmarkMulDecimal-12      15515397    114.8 ns\/op    80 B\/op  2 allocs\/op  PASS ok github.com\/zergon321\/safecomp 3.408s<\/code><\/pre>\n<p>\u042d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 313 \u0440\u0430\u0437 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043d\u043e \u0437\u0430\u0442\u043e \u0442\u043e\u0447\u043d\u043e. \u0411\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u043d\u044b \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0434\u043b\u044f \u043e\u0431\u043e\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u043d\u0434\u043e\u0432. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0449\u0451 \u0431\u043e\u043b\u044c\u0448\u0435. \u0422\u0430\u043a\u0436\u0435 \u044f \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043b \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u0441\u0430\u043c\u043e\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0439 \u043d\u0430 Go \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 Decimal. \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f float \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435 (\u043e\u043d \u0434\u0430\u0435\u0442 \u0442\u0435 \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0441 \/\/go:noinline).<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u0448 \u0441\u043b\u0443\u0447\u0430\u0439 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442 \u0432\u0430\u0441 \u0442\u043e\u0447\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0438\u043c\u0435\u043d\u043d\u043e \u0441 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 <a href=\"https:\/\/github.com\/zergon321\/safecomp\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a>. \u0411\u0443\u0434\u044c\u0442\u0435 \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u044b, \u043a\u0430\u043a \u0443\u0436\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u043e, \u043e\u043d \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.<\/p>\n<\/p>\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\/819843\/\"> https:\/\/habr.com\/ru\/articles\/819843\/<\/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>\u0427\u0438\u0441\u043b\u0430 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 (\u043e\u0434\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u0438\u043b\u0438 \u0434\u0432\u043e\u0439\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438) \u043f\u0435\u0447\u0430\u043b\u044c\u043d\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0437\u0430 \u043d\u0435\u043b\u0435\u043f\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<figure class=\"\">\n<div><figcaption>\u041e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442: 0.3<\/figcaption><\/div>\n<\/figure>\n<figure class=\"\">\n<div><figcaption>\u041e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442: 0.2<\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0438 \u0434\u0430\u0436\u0435 \u043e\u0446\u0435\u043d\u043e\u043a \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0442\u0430\u043a\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439, <a href=\"https:\/\/medium.com\/@ellenaua\/floating-point-errors-in-javascript-node-js-21aadd897bf8\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f JavaScript, \u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0432\u0435\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 <a href=\"https:\/\/ieeexplore.ieee.org\/document\/8766229\" rel=\"noopener noreferrer nofollow\">IEEE-754<\/a> (\u0442.\u0435. \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f).<\/p>\n<h2>\u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442?<\/h2>\n<p>\u0420\u0435\u0441\u0443\u0440\u0441\u044b \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0435\u0442 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u0431\u043e\u043b\u044c\u0448\u0435 255 \u0438\u043b\u0438 \u043c\u0435\u043d\u044c\u0448\u0435 0 \u0432 \u043e\u0434\u043d\u043e\u043c \u0431\u0430\u0439\u0442\u0435. \u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f [-128; 127]. \u0412\u0435\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u044b \u043f\u043e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438. \u0426\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u0432\u044b\u0445\u043e\u0434\u044f\u0442 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b, \u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u0430 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u0432\u044b\u0440\u043e\u0436\u0434\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u043c\u0435\u0440\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"go\">import ( \"fmt\" )  func main() { fmt.Println(float32(16777215.0) == float32(16777216.0)) \/\/ false fmt.Println(float32(16777216.0) == float32(16777217.0)) \/\/ true fmt.Println(float32(16777216.0)) \/\/ 1.6777216e+07 fmt.Println(float32(16777217.0)) \/\/ 1.6777216e+07 }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0434\u0430\u0436\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0432\u043e float32, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0442\u043c\u0435\u0442\u043a\u0438. \u0422\u0438\u043f float64 \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0448\u0438\u0440\u043e\u043a\u0438\u0439 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b, \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u044b\u0445 \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a. \u041d\u043e \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u0430 \u043e\u0442\u043c\u0435\u0442\u043a\u0430? \u041d\u0443, 16 777 216 = 2\u00b2\u00b3 \u00d7 2. \u0410 \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u0430 \u0447\u0438\u0441\u043b\u0430 float32 \u0438\u043c\u0435\u0435\u0442 \u0434\u043b\u0438\u043d\u0443 23 \u0431\u0438\u0442\u0430. \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0438 \u044d\u0442\u043e \u0442\u0430 \u043e\u0442\u043c\u0435\u0442\u043a\u0430, \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0432\u044b\u0440\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f? \u041b\u0435\u0433\u043a\u043e \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"go\">for i := float32(0.0); i &lt;= float32(16777216.0); i += float32(1.0) { if i == 16777215.0 { fmt.Printin(\"halt\") \/\/ breakpoint here }  if i == i+float32(1.0) { fmt.Println(i) \/\/ breakpoint here } }<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0431\u043b\u043e\u043a \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442, \u043f\u043e\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043d\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0435\u0442 16 777 215. \u041a\u043e\u0433\u0434\u0430 \u043e\u043d\u0430 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442 16 777 216, \u0442\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441 16 777 216 + 1, \u0438 \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u0432\u043e float32. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u0434 \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430. \u041f\u043e \u0442\u043e\u0439 \u0436\u0435 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0435\u043b\u044c\u0437\u044f, \u0438 \u0446\u0438\u043a\u043b \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0442\u043e\u0442 \u0436\u0435 \u0432\u044b\u0432\u043e\u0434 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e.<\/p>\n<figure class=\"\"><\/figure>\n<p>\u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0438 \u0432 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438. \u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442:<\/p>\n<pre><code class=\"go\">for i := float32(0.0); i >= -float32(16777216.0); i -= float32(1.0) { if i == -16777215.0 { fmt.Printin(\"halt\") \/\/ breakpoint here }  if i == i-float32(1.0) { fmt.Println(i) \/\/ breakpoint here } }<\/code><\/pre>\n<p>\u041c\u0430\u043d\u0442\u0438\u0441\u0441\u0430 \u0447\u0438\u0441\u043b\u0430 float64 \u0431\u043e\u043b\u044c\u0448\u0435 (52 \u0431\u0438\u0442\u0430 \u0432 \u0434\u043b\u0438\u043d\u0443). \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 [-2\u2075\u00b3; 2\u2075\u00b3]. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d, \u043d\u043e \u0434\u0430, \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e \u0438 \u0437\u0434\u0435\u0441\u044c. \u0412\u043e\u0442 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"go\">package main  import ( \"fmt\" \"math\" )  func main() { fmt.Println(math.Pow(2, 53) == math.Pow(2, 53)-1) \/\/ false fmt.Println(math.Pow(2, 53) == math.Pow(2, 53)+1) \/\/ true }<\/code><\/pre>\n<h2>\u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e?<\/h2>\n<p>&#8212; \u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c. \u042f \u0441\u043b\u044b\u0448\u0430\u043b, \u0432\u044b \u0443\u043c\u0435\u0435\u0442\u0435 \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u0443\u043c\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c. \u0418\u0442\u0430\u043a, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0443\u0434\u0435\u0442 14 * 17?<br \/>&#8212; 230<br \/>&#8212; \u041d\u043e \u044d\u0442\u043e \u043d\u0435\u0432\u0435\u0440\u043d\u043e!<br \/>&#8212; \u0417\u0430\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u043e.<\/p>\n<h2>\u041a\u0430\u043a \u0441 \u044d\u0442\u0438\u043c \u0436\u0438\u0442\u044c<\/h2>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u0430 \u0441 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439, \u0442\u0438\u043f <a href=\"https:\/\/github.com\/shopspring\/decimal\" rel=\"noopener noreferrer nofollow\">Decimal<\/a> \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u0435 (\u0435\u0441\u043b\u0438 \u0432\u044b \u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0435\u0442\u0435, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0446\u0438\u0444\u0440 \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0447\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u0432\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435). \u0415\u0441\u043b\u0438 \u0432 \u0432\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u043c\u0435\u0442\u044c \u0434\u0435\u043b\u043e \u0441 \u0434\u0435\u043d\u0435\u0436\u043d\u044b\u043c\u0438 \u0435\u0434\u0438\u043d\u0438\u0446\u0430\u043c\u0438, \u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c <a href=\"https:\/\/github.com\/Rhymond\/go-money\" rel=\"noopener noreferrer nofollow\">\u0448\u0430\u0431\u043b\u043e\u043d \u041c\u0430\u0440\u0442\u0438\u043d\u0430 \u0424\u0430\u0443\u043b\u0435\u0440\u0430 \u0434\u043b\u044f \u0432\u0430\u043b\u044e\u0442\u043d\u044b\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d<\/a>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u0436\u0435\u043b\u0435\u0437\u043d\u043e \u043d\u0430\u0434\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c float \u0438 \u0432\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a\u043e\u0432\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u044f, \u0443 \u043c\u0435\u043d\u044f \u0435\u0441\u0442\u044c \u0434\u043b\u044f \u0432\u0430\u0441 \u0445\u0438\u0442\u0440\u043e\u0443\u043c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<h2>\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438<\/h2>\n<p>\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u0445 \u043d\u0430\u0434 \u0434\u0432\u0443\u043c\u044f \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439:<\/p>\n<ul>\n<li>\n<p>\u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u044b \u0432\u044b\u0448\u0435\u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u043c\u0438 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430\u043c\u0438 ([-2\u00b2\u2074, 2\u00b2\u2074] \u0434\u043b\u044f float32, [-2\u2075\u00b3; 2\u2075\u00b3] \u0434\u043b\u044f float64); \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445;<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b (\u0442\u0435 \u0436\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430);<\/p>\n<\/li>\n<li>\n<p>\u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b (\u0442\u0435 \u0436\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430);<\/p>\n<\/li>\n<li>\n<p>\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b (\u0442\u0435 \u0436\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430);<\/p>\n<\/li>\n<li>\n<p>\u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043b\u044e\u0431\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 (\u0446\u0435\u043b\u043e\u0433\u043e \u0438\u043b\u0438 \u0434\u0440\u043e\u0431\u043d\u043e\u0433\u043e) \u043d\u0430 10 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 n, \u0433\u0434\u0435 n \u2265 0, n \u2014 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e;<\/p>\n<\/li>\n<li>\n<p>\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043b\u044e\u0431\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 (\u0446\u0435\u043b\u043e\u0433\u043e \u0438\u043b\u0438 \u0434\u0440\u043e\u0431\u043d\u043e\u0433\u043e) \u043d\u0430 10 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 n, \u0433\u0434\u0435 n \u2265 0, n \u2014 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e;<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0433\u043e, \u0435\u0441\u043b\u0438 \u0431\u0443\u0434\u0435\u0442\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0432\u044b\u0448\u0435\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u0447\u0435\u0440\u0435\u0437 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f.<\/p>\n<h2>\u0422\u0435\u043e\u0440\u0438\u044f<\/h2>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u0442\u044c 3,8 \u043a 2,56. \u0415\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044f\u0437\u044b\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0432\u0435\u0440\u043d\u0443\u043b \u0431\u044b 6,359999999999999. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0448\u043a\u043e\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0434\u0432\u0430 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 \u0438 \u0434\u0435\u043b\u0438\u043c \u0438\u0445 \u043d\u0430 10\u00b2. \u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e \u0438 \u043a \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u044e. \u041e\u0434\u043d\u0430\u043a\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c \u043d\u0438\u0436\u0435:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e, \u0432\u0441\u0435 \u0434\u0435\u043b\u043e \u0432 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0438 \u0434\u043b\u0438\u043d\u044b \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0447\u0438\u0441\u043b\u0430 \u0438 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0438 \u0435\u0435 \u043d\u0430 10 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u044d\u0442\u043e\u0439 \u0434\u043b\u0438\u043d\u044b. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0446\u0435\u043b\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u0432\u0435\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445. \u0412 \u043a\u043e\u043d\u0446\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u0440\u043e\u0431\u043d\u044b\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 10 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430.<\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u044f \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u2014 \u044d\u0442\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0440\u0435\u0434\u0438 \u043e\u0431\u043e\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u043d\u0434\u043e\u0432. \u0412 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0438 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u2014 \u044d\u0442\u043e \u0441\u0443\u043c\u043c\u0430 \u0434\u043b\u0438\u043d \u0434\u0440\u043e\u0431\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u043e\u0431\u043e\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u043d\u0434\u043e\u0432. \u041d\u043e \u0441 \u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0432\u0441\u0451 \u043d\u0435 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e. \u0415\u0441\u0442\u044c \u0442\u0440\u0438 \u0441\u043b\u0443\u0447\u0430\u044f:<\/p>\n<ul>\n<li>\n<p>\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0434\u043b\u0438\u043d\u0443 \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u0447\u0435\u043c \u0437\u043d\u0430\u043c\u0435\u043d\u0430\u0442\u0435\u043b\u044c:<\/p>\n<figure class=\"full-width\"><\/figure>\n<\/li>\n<li>\n<p>\u0437\u043d\u0430\u043c\u0435\u043d\u0430\u0442\u0435\u043b\u044c \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0434\u043b\u0438\u043d\u0443 \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u0447\u0435\u043c \u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c:<\/p>\n<figure class=\"full-width\"><\/figure>\n<\/li>\n<li>\n<p>\u0434\u0440\u043e\u0431\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 \u043e\u0431\u043e\u0438\u0445 \u0447\u0438\u0441\u0435\u043b \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b \u043f\u043e \u0434\u043b\u0438\u043d\u0435:<\/p>\n<figure class=\"\"><\/figure>\n<\/li>\n<\/ul>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0434\u0435\u043b\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0412 \u0442\u0440\u0435\u0442\u044c\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u043a\u0430\u043a \u0435\u0441\u0442\u044c.<\/p>\n<h2>\u041d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u043d\u044b \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/h2>\n<p>\u041a\u0430\u043a \u0432\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u043a\u0430\u0436\u0434\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0434\u043b\u0438\u043d\u044b \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u043d\u0434\u0430. \u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0443\u043c, \u2014 \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 \u043b\u043e\u0431, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 \u0438\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442:<\/p>\n<pre><code class=\"go\">import ( \"strconv\" \"strings\" )  func GetPartsLength(number float64) (int, int) { numStr := strconv.FormatFloat(number, 'f', -1, 64) numStr = strings.TrimPrefix(numStr, \"-\") parts := strings.Split(numStr, \".\")  if len(parts) > 1 { return len(parts[0]), len(parts[1]) }  if len(parts) == 1 { return len(parts[0]), 0 }  return -1, -1 }<\/code><\/pre>\n<p>\u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u043b\u0438\u043d\u0443 \u0446\u0435\u043b\u043e\u0439 \u0438 \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0435\u0439 \u0447\u0438\u0441\u043b\u0430. \u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u044d\u0442\u043e \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c, \u043d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u043c\u0435\u0440\u0438\u043c \u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c:<\/p>\n<pre><code class=\"go\">func BenchmarkGetPartsLength(b *testing.B) { for i := 0; i &lt; b.N; i++ { safecomp.GetPartsLength(-19367.5889) } }<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0432\u043e\u043e\u0434\u0443\u0448\u0435\u0432\u043b\u044f\u044e\u0449\u0438\u0439:<\/p>\n<pre><code>Running tool: \/usr\/bin\/go test -benchmem -run=A$ \\ -bench ABenchmarkGetPartsLength$ ieee-754\/safecomp  goos: linux goarch: amd64 pkg: ieee-754\/safecomp cpu: AMD Ryzen 5 5600H with Radeon Graphics  BenchmarkGetPartsLength-12  7736520   263.0 ns\/op  72 B\/op   3 allocs\/op  PASS ok ieee-754\/safecomp 2.196s<\/code><\/pre>\n<p>\u0421\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0432\u0435\u0441\u044c\u043c\u0430 \u0437\u0430\u0442\u0440\u0430\u0442\u043d\u044b \u0432 \u043f\u043b\u0430\u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0426\u041f \u0438 \u041e\u0417\u0423. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043e\u043d\u0438 \u0447\u0430\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u0414\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e strconv.FormatFloat \u0434\u043e\u043b\u0436\u0435\u043d \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0437\u043d\u0430\u0442\u044c, \u0433\u0434\u0435 \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0442\u043e\u0447\u043a\u0443 \u0432 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0447\u0438\u0441\u043b\u0430 \u0442\u0438\u043f\u0430 float. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0421\u0442\u044d\u043a \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f ryuFtoaShortest \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c Ry\u016b. \u041e\u043d\u0430 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0442\u0438\u043f\u0430 decimalSlice:<\/p>\n<pre><code class=\"go\">type decimalslice struct { d      []byte nd, dp int neg    bool }<\/code><\/pre>\n<p>nd \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u00ab\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0446\u0438\u0444\u0440\u00bb. \u041e\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442 \u043e\u0431\u0449\u0443\u044e \u0434\u043b\u0438\u043d\u0443 \u0447\u0438\u0441\u043b\u0430, \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f \u0437\u043d\u0430\u043a \u0438 \u0442\u043e\u0447\u043a\u0443. dp \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u00ab\u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c\u00bb. \u041e\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442 \u0434\u043b\u0438\u043d\u0443 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u0438\u043d\u0430 \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0440\u0430\u0432\u043d\u0430 nd &#8212; dp.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u043d\u0430\u0448\u0435\u0439 \u0446\u0435\u043b\u0438. \u041e\u043d\u0438 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \/usr\/lib\/go\/src\/strconv. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u0443\u0442\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438, \u0432\u0435\u0440\u0441\u0438\u0438 \u044f\u0437\u044b\u043a\u0430, \u041e\u0421 \u0438 \u0442. \u0434. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b \u0438\u0437 \u043f\u0430\u043a\u0435\u0442\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u044b\u043b\u043e \u0431\u044b \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0443\u0442\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c-\u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e. \u0412\u043e\u0442 \u043f\u043e\u0447\u0435\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0432\u0435\u0441\u044c \u043f\u0430\u043a\u0435\u0442 \u0432 \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442. \u0418 \u0432\u043e\u0442 \u043a \u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u043b\u043e:<\/p>\n<pre><code>[zergon321@astroemeria ieee-754]$ go run main.go package command-line-arguments   imports ieee-754\/alt   alt\/bytealg.go:10:8: use of internal package internal\/bytealg not allowed<\/code><\/pre>\n<p>\u0423\u043f\u0441. \u0427\u0442\u043e \u0436, \u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0434\u0430\u043b\u0438\u043b \u0444\u0430\u0439\u043b bytealg.go \u0438 \u0432\u0441\u0451, \u0447\u0442\u043e \u043e\u0442 \u043d\u0435\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0435\u043b\u043e. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0444\u0443\u043d\u043a\u0446\u0438\u044f genericFtoa \u043a \u0442\u0430\u043a\u043e\u0432\u043e\u043c\u0443 \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u043b\u0430\u0441\u044c. \u0412\u0441\u0435 \u043c\u043e\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u0440\u0438\u0432\u0435\u043b\u0438 \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e GetPartsLength, \u0447\u0442\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435:<\/p>\n<pre><code class=\"go\">package alt  import \"math\"  func GetPartsLength(val float64, fmt byte, prec, bitSize int) (int, int) { var bits uint64 var flt *floatInfo switch bitSize { case 32: bits = uint64(math.Float32bits(float32(val))) flt = &amp;float32info case 64: bits = math.Float64bits(val) flt = &amp;float64info default: panic(\"strconv: illegal AppendFloat\/FormatFloat bitSize\") }  exp := int(bits>>flt.mantbits) &amp; (1&lt;&lt;flt.expbits - 1) mant := bits &amp; (uint64(1)&lt;&lt;flt.mantbits - 1)  switch exp { case 1&lt;&lt;flt.expbits - 1: \/\/ Inf, NaN return -1, -1  case 0: \/\/ denormalized exp++  default: \/\/ add implicit top bit mant |= uint64(1) &lt;&lt; flt.mantbits } exp += flt.bias  var digs decimalSlice \/\/ Negative precision means \"only as much as needed to be exact.\" shortest := prec &lt; 0 if shortest { \/\/ Use Ryu algorithm. var buf [32]byte digs.d = buf[:] ryuFtoaShortest(&amp;digs, mant, exp-int(flt.mantbits), flt) } else if fmt != 'f' { \/\/ Fixed number of digits. digits := prec switch fmt { case 'e', 'E': digits++ case 'g', 'G': if prec == 0 { prec = 1 } digits = prec default: \/\/ Invalid mode. digits = 1 } var buf [24]byte if bitSize == 32 &amp;&amp; digits &lt;= 9 { digs.d = buf[:] ryuFtoaFixed32(&amp;digs, uint32(mant), exp-int(flt.mantbits), digits) } else if digits &lt;= 18 { digs.d = buf[:] ryuFtoaFixed64(&amp;digs, mant, exp-int(flt.mantbits), digits) } }  return digs.dp, digs.nd - digs.dp }<\/code><\/pre>\n<p>\u042d\u0442\u043e \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e, \u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435:<\/p>\n<pre><code>Running tool: \/usr\/bin\/go test -benchmem -run=A$ \\ -bench ABenchmarkGetPartsLength$ ieee-754\/test  goos: linux goarch:<\/code><\/pre>\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-378242","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/378242","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=378242"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/378242\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=378242"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=378242"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=378242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}