{"id":106827,"date":"2026-09-18T11:48:52","date_gmt":"2026-09-18T03:48:52","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/106827.html"},"modified":"2026-09-18T11:48:52","modified_gmt":"2026-09-18T03:48:52","slug":"%e7%b1%bb%e5%9e%8b%e8%bd%ac%e6%8d%a2%e7%b2%be%e5%ba%a6%e4%b8%a2%ef%bc%9aint-%e8%bd%ac-float-%e6%88%aa%e6%96%ad%ef%bc%8c%e5%85%88%e8%bd%ac%e5%ae%bd%e7%b1%bb%e5%9e%8b%e5%86%8d%e7%ae%97","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/106827.html","title":{"rendered":"\u7c7b\u578b\u8f6c\u6362\u7cbe\u5ea6\u4e22\uff1aint \u8f6c float \u622a\u65ad\uff0c\u5148\u8f6c\u5bbd\u7c7b\u578b\u518d\u7b97"},"content":{"rendered":"<h2>\u7c7b\u578b\u8f6c\u6362\u7cbe\u5ea6\u4e22&#xff1a;int \u8f6c float \u622a\u65ad&#xff0c;\u5148\u8f6c\u5bbd\u7c7b\u578b\u518d\u7b97<\/h2>\n<p>\u6458\u8981&#xff1a;\u672c\u6587\u901a\u8fc7\u4e00\u4e2a ADC \u6807\u5ea6\u6362\u7b97\u7ffb\u8f66\u6848\u4f8b&#xff0c;\u8bb2\u89e3 C \u8bed\u8a00\u4e2d int\/int \u6574\u6570\u9664\u6cd5\u622a\u65ad\u5bfc\u81f4\u7684\u7cbe\u5ea6\u4e22\u5931\u95ee\u9898\u3002\u6838\u5fc3\u539f\u56e0&#xff1a;\u4e24\u4e2a\u6574\u6570\u76f8\u9664\u7ed3\u679c\u4ecd\u662f\u6574\u6570&#xff0c;\u5c0f\u6570\u5728\u6574\u6570\u9636\u6bb5\u5df2\u88ab\u4e22\u5f03&#xff0c;\u518d\u8d4b\u7ed9 float \u4e3a\u65f6\u5df2\u665a\u3002\u89e3\u6cd5\u662f\u5728\u8fd0\u7b97\u524d\u628a\u64cd\u4f5c\u6570\u8f6c\u6210\u6d6e\u70b9&#xff08;(float)raw \/ 4095 \u6216\u4e58 1.0f&#xff09;&#xff0c;\u8ba9\u9664\u6cd5\u5728\u6d6e\u70b9\u57df\u8fdb\u884c\u3002\u6587\u4e2d\u9644\u9519\u8bef\u7248\u4e0e\u6b63\u786e\u7248\u4ee3\u7801\u3001\u65b9\u6848\u5bf9\u6bd4\u53ca -Wconversion \u914d\u7f6e\u5efa\u8bae&#xff0c;\u5e76\u5ef6\u4f38\u4ecb\u7ecd\u65e0 FPU MCU \u7684 Q \u683c\u5f0f\u5b9a\u70b9\u6570\u65b9\u6848\u3002<\/p>\n<h3>\u4e00\u3001\u5f00\u7bc7&#xff1a;\u4e00\u4e2a\u771f\u5b9e\u7ffb\u8f66\u73b0\u573a<\/h3>\n<p>\u4e00\u6bb5\u505a\u6807\u5ea6\u6362\u7b97\u7684\u4ee3\u7801&#xff1a;int raw &#061; 4095; float v &#061; raw \/ 4095 * 3.3f;&#xff0c;\u672c\u610f\u628a ADC \u539f\u59cb\u503c\u6362\u7b97\u6210\u7535\u538b\u3002\u7ed3\u679c v \u7b97\u51fa\u6765\u662f 0.0 \u6216 3.3 \u8df3\u53d8&#xff0c;\u4e2d\u95f4\u503c\u5168\u4e22\u3002\u539f\u56e0&#xff1a;raw \/ 4095 \u662f\u4e24\u4e2a\u6574\u6570\u76f8\u9664&#xff0c;\u7ed3\u679c\u5148\u6309\u6574\u6570\u7b97&#xff08;4095\/4095&#061;1&#xff0c;\u4f46\u82e5\u662f 2000\/4095&#061;0&#xff09;&#xff0c;\u518d\u8f6c float \u2192 \u7cbe\u5ea6\u5728\u6574\u6570\u9664\u6cd5\u90a3\u6b65\u5c31\u4e22\u4e86\u3002<\/p>\n<p>\u6839\u56e0\u4e00\u53e5\u8bdd&#xff1a;C \u4e2d&#034;\u4e24\u4e2a\u540c\u7c7b\u578b\u64cd\u4f5c\u6570\u8fd0\u7b97&#xff0c;\u7ed3\u679c\u4e5f\u662f\u8be5\u7c7b\u578b&#034;\u3002int \/ int \u505a\u6574\u6570\u9664\u6cd5&#xff08;\u622a\u65ad\u5c0f\u6570&#xff09;&#xff0c;\u518d\u8d4b\u503c\u7ed9 float \u5df2\u7ecf\u665a\u4e86\u2014\u2014\u5c0f\u6570\u5df2\u5728\u6574\u6570\u9636\u6bb5\u4e22\u5931\u3002\u89e3\u6cd5&#xff1a;\u8fd0\u7b97\u524d\u628a\u81f3\u5c11\u4e00\u4e2a\u64cd\u4f5c\u6570\u8f6c\u6210\u6d6e\u70b9&#xff08;(float)raw \/ 4095 \u6216\u4e58 1.0f&#xff09;&#xff0c;\u8ba9\u9664\u6cd5\u5728\u6d6e\u70b9\u57df\u8fdb\u884c&#xff0c;\u4fdd\u7559\u7cbe\u5ea6\u3002<\/p>\n<p>\u9002\u7528\u8bfb\u8005&#xff1a;\u505a int\/int \u518d\u8d4b\u7ed9 float\u3001\u53d1\u73b0\u5c0f\u6570\u90e8\u5206\u5168\u4e22\/\u7ed3\u679c\u8df3\u53d8\u7684\u540c\u5b66\u3002<br \/>\n\u8bfb\u5b8c\u4f60\u80fd\u505a&#xff1a;\u8bc6\u522b\u6574\u6570\u9664\u6cd5\u622a\u65ad\u5bfc\u81f4\u7684\u7cbe\u5ea6\u4e22\u5931&#xff0c;\u7528&#034;\u5148\u8f6c\u6d6e\u70b9\u518d\u8fd0\u7b97&#034;\u4fdd\u7559\u7cbe\u5ea6\u3002<\/p>\n<h3>\u4e8c\u3001\u5148\u641e\u61c2&#xff1a;\u6574\u6570\u9664\u6cd5\u622a\u65ad&#xff08;\u8ba4\u77e5&#xff09;<\/h3>\n<h4>2.1 \u540c\u7c7b\u578b\u8fd0\u7b97\u89c4\u5219<\/h4>\n<p>C \u7684&#034;\u5bfb\u5e38\u7b97\u672f\u8f6c\u6362&#034;&#xff1a;\u4e24\u4e2a\u6574\u6570\u64cd\u4f5c\u6570\u8fd0\u7b97&#xff0c;\u7ed3\u679c\u8fd8\u662f\u6574\u6570&#xff0c;\u9664\u6cd5\u5411\u96f6\u622a\u65ad&#xff08;\u4e22\u5f03\u5c0f\u6570&#xff09;\u30025\/2 &#061; 2&#xff0c;2000\/4095 &#061; 0\u3002\u53ea\u6709\u8fd0\u7b97\u7ed3\u679c\u8d4b\u7ed9 float \u624d\u4f1a\u8f6c&#xff0c;\u4f46\u8f6c\u6362\u53d1\u751f\u5728\u8fd0\u7b97\u4e4b\u540e&#xff0c;\u5c0f\u6570\u5df2\u6ca1\u4e86\u3002<\/p>\n<h4>2.2 \u4e3a\u4ec0\u4e48\u7cbe\u5ea6\u4e22<\/h4>\n<p>raw \/ 4095&#xff1a;raw \u548c 4095 \u90fd\u662f int \u2192 \u6574\u6570\u9664\u6cd5&#xff0c;\u622a\u65ad\u3002\u5373\u4f7f\u5de6\u8fb9\u662f 2000&#xff0c;\u7ed3\u679c 0&#xff0c;\u518d *3.3f \u5f97 0.0f\u3002\u4e2d\u95f4\u503c\u7cbe\u5ea6\u5728\u6574\u6570\u9636\u6bb5\u5df2\u6ca1\u3002<\/p>\n<table>\n<tr>\u5199\u6cd5\u7ed3\u679c<\/tr>\n<tbody>\n<tr>\n<td>2000\/4095*3.3f<\/td>\n<td>0.0&#xff08;\u622a\u65ad&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>(float)2000\/4095*3.3f<\/td>\n<td>1.612<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>#mermaid-svg-9xF4GWbIHLXy5AjM{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-9xF4GWbIHLXy5AjM .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-9xF4GWbIHLXy5AjM .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-9xF4GWbIHLXy5AjM .error-icon{fill:#552222;}#mermaid-svg-9xF4GWbIHLXy5AjM .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-9xF4GWbIHLXy5AjM .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-9xF4GWbIHLXy5AjM .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-9xF4GWbIHLXy5AjM .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-9xF4GWbIHLXy5AjM .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-9xF4GWbIHLXy5AjM .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-9xF4GWbIHLXy5AjM .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-9xF4GWbIHLXy5AjM .marker{fill:#333333;stroke:#333333;}#mermaid-svg-9xF4GWbIHLXy5AjM .marker.cross{stroke:#333333;}#mermaid-svg-9xF4GWbIHLXy5AjM svg{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-9xF4GWbIHLXy5AjM p{margin:0;}#mermaid-svg-9xF4GWbIHLXy5AjM .label{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;color:#333;}#mermaid-svg-9xF4GWbIHLXy5AjM .cluster-label text{fill:#333;}#mermaid-svg-9xF4GWbIHLXy5AjM .cluster-label span{color:#333;}#mermaid-svg-9xF4GWbIHLXy5AjM .cluster-label span p{background-color:transparent;}#mermaid-svg-9xF4GWbIHLXy5AjM .label text,#mermaid-svg-9xF4GWbIHLXy5AjM span{fill:#333;color:#333;}#mermaid-svg-9xF4GWbIHLXy5AjM .node rect,#mermaid-svg-9xF4GWbIHLXy5AjM .node circle,#mermaid-svg-9xF4GWbIHLXy5AjM .node ellipse,#mermaid-svg-9xF4GWbIHLXy5AjM .node polygon,#mermaid-svg-9xF4GWbIHLXy5AjM .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-9xF4GWbIHLXy5AjM .rough-node .label text,#mermaid-svg-9xF4GWbIHLXy5AjM .node .label text,#mermaid-svg-9xF4GWbIHLXy5AjM .image-shape .label,#mermaid-svg-9xF4GWbIHLXy5AjM .icon-shape .label{text-anchor:middle;}#mermaid-svg-9xF4GWbIHLXy5AjM .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-9xF4GWbIHLXy5AjM .rough-node .label,#mermaid-svg-9xF4GWbIHLXy5AjM .node .label,#mermaid-svg-9xF4GWbIHLXy5AjM .image-shape .label,#mermaid-svg-9xF4GWbIHLXy5AjM .icon-shape .label{text-align:center;}#mermaid-svg-9xF4GWbIHLXy5AjM .node.clickable{cursor:pointer;}#mermaid-svg-9xF4GWbIHLXy5AjM .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-9xF4GWbIHLXy5AjM .arrowheadPath{fill:#333333;}#mermaid-svg-9xF4GWbIHLXy5AjM .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-9xF4GWbIHLXy5AjM .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-9xF4GWbIHLXy5AjM .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-9xF4GWbIHLXy5AjM .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-9xF4GWbIHLXy5AjM .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-9xF4GWbIHLXy5AjM .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-9xF4GWbIHLXy5AjM .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-9xF4GWbIHLXy5AjM .cluster text{fill:#333;}#mermaid-svg-9xF4GWbIHLXy5AjM .cluster span{color:#333;}#mermaid-svg-9xF4GWbIHLXy5AjM div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-9xF4GWbIHLXy5AjM .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-9xF4GWbIHLXy5AjM rect.text{fill:none;stroke-width:0;}#mermaid-svg-9xF4GWbIHLXy5AjM .icon-shape,#mermaid-svg-9xF4GWbIHLXy5AjM .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-9xF4GWbIHLXy5AjM .icon-shape p,#mermaid-svg-9xF4GWbIHLXy5AjM .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-9xF4GWbIHLXy5AjM .icon-shape .label rect,#mermaid-svg-9xF4GWbIHLXy5AjM .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-9xF4GWbIHLXy5AjM .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-9xF4GWbIHLXy5AjM .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-9xF4GWbIHLXy5AjM :root{&#8211;mermaid-font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;}<span class=\"edgeLabel\"><\/span><span class=\"edgeLabel\"><\/p>\n<p>int\u9664\u6cd5<\/p>\n<p><\/span><span class=\"edgeLabel\"><\/p>\n<p>\u8f6cfloat\u518d\u9664<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>raw\/4095*3.3f<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>\u9664\u6cd5\u57df?<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>\u622a\u65ad \u7cbe\u5ea6\u4e22<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>\u4fdd\u7559\u5c0f\u6570<\/p>\n<p><\/span><\/p>\n<p>\u56fe 1&#xff1a;\u6574\u6570\u9664\u6cd5\u622a\u65ad&#xff08;\u5982\u56fe 1 \u6240\u793a&#xff0c;\u5148\u8f6c\u6d6e\u70b9\u624d\u4fdd\u7cbe\u5ea6&#xff09;\u3002<\/p>\n<p>[\u6ce8\u610f] \u53cd\u8fc7\u6765 float \u8f6c int \u4e5f\u4f1a\u4e22\u5c0f\u6570&#xff08;\u5411\u96f6\u622a\u65ad&#xff09;&#xff0c;\u4e14\u5927 float \u8f6c int \u53ef\u80fd\u6ea2\u51fa\u672a\u5b9a\u4e49&#xff08;float \u8303\u56f4\u8fdc\u5927\u4e8e int&#xff09;\u3002\u6df7\u5408\u8fd0\u7b97\u8981\u6e05\u695a\u6bcf\u6b65\u7c7b\u578b\u3002<\/p>\n<h3>\u4e09\u3001\u4e3a\u4ec0\u4e48\u4f1a\u4e22\u7cbe\u5ea6&#xff08;\u539f\u7406 &#043; \u771f\u5b9e\u9519\u8bef\u4ee3\u7801&#xff09;<\/h3>\n<h4>3.1 \u9519\u8bef\u7248<\/h4>\n<p><span class=\"token comment\">\/\/ \u274c \u9519&#xff1a;int\/int \u5148\u622a\u65ad\u518d\u8f6c float<\/span><br \/>\n<span class=\"token keyword\">int<\/span> raw <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">2000<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">float<\/span> v <span class=\"token operator\">&#061;<\/span> raw <span class=\"token operator\">\/<\/span> <span class=\"token number\">4095<\/span> <span class=\"token operator\">*<\/span> <span class=\"token number\">3.3f<\/span><span class=\"token punctuation\">;<\/span>        <span class=\"token comment\">\/\/ raw\/4095 \u662f\u6574\u6570\u9664\u6cd5 &#061; 0 \u2192 v &#061; 0.0<\/span><br \/>\n<span class=\"token comment\">\/\/ \u671f\u671b\u7ea6 1.612V&#xff0c;\u5b9e\u9645 0.0<\/span><\/p>\n<p>\u9519&#xff1a;\u2460raw(int) \/ 4095(int) \u2192 \u6574\u6570\u9664\u6cd5 &#061;0&#xff1b;\u24610 * 3.3f &#061; 0.0f&#xff1b;\u2462\u5c0f\u6570\u5728\u6574\u6570\u9636\u6bb5\u4e22\u5931\u3002<\/p>\n<p>[\u5751] \u94c1\u5f8b&#xff1a;\u542b\u9664\u6cd5\u7684\u6807\u5ea6\u6362\u7b97&#xff0c;\u8fd0\u7b97\u524d\u628a\u64cd\u4f5c\u6570\u8f6c\u6210\u6d6e\u70b9&#xff0c;\u907f\u514d\u6574\u6570\u9664\u6cd5\u622a\u65ad\u3002<\/p>\n<p>\u9519\u8bef\u94fe\u8def\u5982\u4e0b&#xff1a;<\/p>\n<p>#mermaid-svg-XCKWDqOJiXtYEZPq{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-XCKWDqOJiXtYEZPq .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-XCKWDqOJiXtYEZPq .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-XCKWDqOJiXtYEZPq .error-icon{fill:#552222;}#mermaid-svg-XCKWDqOJiXtYEZPq .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-XCKWDqOJiXtYEZPq .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-XCKWDqOJiXtYEZPq .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-XCKWDqOJiXtYEZPq .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-XCKWDqOJiXtYEZPq .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-XCKWDqOJiXtYEZPq .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-XCKWDqOJiXtYEZPq .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-XCKWDqOJiXtYEZPq .marker{fill:#333333;stroke:#333333;}#mermaid-svg-XCKWDqOJiXtYEZPq .marker.cross{stroke:#333333;}#mermaid-svg-XCKWDqOJiXtYEZPq svg{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-XCKWDqOJiXtYEZPq p{margin:0;}#mermaid-svg-XCKWDqOJiXtYEZPq .label{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;color:#333;}#mermaid-svg-XCKWDqOJiXtYEZPq .cluster-label text{fill:#333;}#mermaid-svg-XCKWDqOJiXtYEZPq .cluster-label span{color:#333;}#mermaid-svg-XCKWDqOJiXtYEZPq .cluster-label span p{background-color:transparent;}#mermaid-svg-XCKWDqOJiXtYEZPq .label text,#mermaid-svg-XCKWDqOJiXtYEZPq span{fill:#333;color:#333;}#mermaid-svg-XCKWDqOJiXtYEZPq .node rect,#mermaid-svg-XCKWDqOJiXtYEZPq .node circle,#mermaid-svg-XCKWDqOJiXtYEZPq .node ellipse,#mermaid-svg-XCKWDqOJiXtYEZPq .node polygon,#mermaid-svg-XCKWDqOJiXtYEZPq .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-XCKWDqOJiXtYEZPq .rough-node .label text,#mermaid-svg-XCKWDqOJiXtYEZPq .node .label text,#mermaid-svg-XCKWDqOJiXtYEZPq .image-shape .label,#mermaid-svg-XCKWDqOJiXtYEZPq .icon-shape .label{text-anchor:middle;}#mermaid-svg-XCKWDqOJiXtYEZPq .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-XCKWDqOJiXtYEZPq .rough-node .label,#mermaid-svg-XCKWDqOJiXtYEZPq .node .label,#mermaid-svg-XCKWDqOJiXtYEZPq .image-shape .label,#mermaid-svg-XCKWDqOJiXtYEZPq .icon-shape .label{text-align:center;}#mermaid-svg-XCKWDqOJiXtYEZPq .node.clickable{cursor:pointer;}#mermaid-svg-XCKWDqOJiXtYEZPq .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-XCKWDqOJiXtYEZPq .arrowheadPath{fill:#333333;}#mermaid-svg-XCKWDqOJiXtYEZPq .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-XCKWDqOJiXtYEZPq .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-XCKWDqOJiXtYEZPq .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-XCKWDqOJiXtYEZPq .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-XCKWDqOJiXtYEZPq .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-XCKWDqOJiXtYEZPq .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-XCKWDqOJiXtYEZPq .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-XCKWDqOJiXtYEZPq .cluster text{fill:#333;}#mermaid-svg-XCKWDqOJiXtYEZPq .cluster span{color:#333;}#mermaid-svg-XCKWDqOJiXtYEZPq div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-XCKWDqOJiXtYEZPq .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-XCKWDqOJiXtYEZPq rect.text{fill:none;stroke-width:0;}#mermaid-svg-XCKWDqOJiXtYEZPq .icon-shape,#mermaid-svg-XCKWDqOJiXtYEZPq .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-XCKWDqOJiXtYEZPq .icon-shape p,#mermaid-svg-XCKWDqOJiXtYEZPq .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-XCKWDqOJiXtYEZPq .icon-shape .label rect,#mermaid-svg-XCKWDqOJiXtYEZPq .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-XCKWDqOJiXtYEZPq .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-XCKWDqOJiXtYEZPq .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-XCKWDqOJiXtYEZPq :root{&#8211;mermaid-font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;}<span class=\"edgeLabel\"><\/span><span class=\"edgeLabel\"><\/span><span class=\"edgeLabel\"><\/p>\n<p>\u662f<\/p>\n<p><\/span><span class=\"edgeLabel\"><\/span><span class=\"edgeLabel\"><\/span><span class=\"edgeLabel\"><\/p>\n<p>\u5426<\/p>\n<p><\/span><span class=\"edgeLabel\"><\/span><span class=\"nodeLabel\"><\/p>\n<p>int raw &#061; 2000<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>raw \/ 4095<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>\u4e24\u4e2a int \u76f8\u9664?<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>\u6574\u6570\u9664\u6cd5 \u622a\u65ad &#061; 0<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>0 * 3.3f &#061; 0.0f<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>v &#061; 0.0V&#xff08;\u9519&#xff09;<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>\u6d6e\u70b9\u9664\u6cd5 \u4fdd\u7559\u5c0f\u6570<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>v &#061; 1.612V&#xff08;\u5bf9&#xff09;<\/p>\n<p><\/span><\/p>\n<h4>3.2 \u4e3a\u4ec0\u4e48&#034;\u7aef\u70b9\u5bf9\u3001\u4e2d\u95f4\u9519&#034;<\/h4>\n<p>raw&#061;0 \u2192 0&#xff08;\u5bf9&#xff09;&#xff0c;raw&#061;4095 \u2192 1*3.3&#061;3.3&#xff08;\u5bf9&#xff09;&#xff0c;\u4e2d\u95f4\u503c&#xff08;\u5982 2000&#xff09;\u5168\u88ab\u622a\u65ad\u6210 0 \u2192 \u8868\u73b0\u4e3a&#034;\u8df3\u53d8\/\u4e22\u7cbe\u5ea6&#034;\u3002<\/p>\n<h3>\u56db\u3001\u6b63\u786e\u89e3\u6cd5&#xff1a;\u5148\u8f6c\u6d6e\u70b9\u518d\u8fd0\u7b97&#xff08;\u5b8c\u6574\u843d\u5730&#xff09;<\/h3>\n<h4>4.1 \u65b9\u6848\u5bf9\u6bd4<\/h4>\n<table>\n<tr>\u65b9\u6848\u7cbe\u5ea6\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>int\/int \u518d\u8f6c float<\/td>\n<td>\u4e22<\/td>\n<td>\u9519<\/td>\n<\/tr>\n<tr>\n<td>\u8f6c float \u518d\u9664<\/td>\n<td>\u4fdd<\/td>\n<td>\u6b63\u89e3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>4.2 \u914d\u7f6e&#xff08;\u7167\u7740\u70b9&#xff09;<\/h4>\n<p>\u5f00 -Wconversion&#xff08;GCC&#xff09;\u4f1a\u5bf9\u9690\u5f0f\u7a84\u5316\u8f6c\u6362\u8b66\u544a\u3002<\/p>\n<h4>4.3 \u5b8c\u6574\u4ee3\u7801<\/h4>\n<p><span class=\"token comment\">\/\/ \u2705 \u6b63\u786e&#xff1a;\u8fd0\u7b97\u524d\u8f6c\u6d6e\u70b9<\/span><br \/>\n<span class=\"token keyword\">int<\/span> raw <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">2000<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">float<\/span> v <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">float<\/span><span class=\"token punctuation\">)<\/span>raw <span class=\"token operator\">\/<\/span> <span class=\"token number\">4095.0f<\/span> <span class=\"token operator\">*<\/span> <span class=\"token number\">3.3f<\/span><span class=\"token punctuation\">;<\/span>     <span class=\"token comment\">\/\/ \u6d6e\u70b9\u57df\u9664\u6cd5&#xff0c;\u4fdd\u7559\u5c0f\u6570 \u2192 1.612V<\/span><br \/>\n<span class=\"token comment\">\/\/ \u6216\u4e58 1.0f \u89e6\u53d1\u63d0\u5347<\/span><br \/>\n<span class=\"token keyword\">float<\/span> v2 <span class=\"token operator\">&#061;<\/span> raw <span class=\"token operator\">*<\/span> <span class=\"token number\">1.0f<\/span> <span class=\"token operator\">\/<\/span> <span class=\"token number\">4095<\/span> <span class=\"token operator\">*<\/span> <span class=\"token number\">3.3f<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>[\u5751] \u4e24\u4e2a\u7ffb\u8f66\u70b9\u6536\u597d&#xff1a;<\/p>\n<li>int\/int \u5148\u622a\u65ad\u2014\u2014\u7cbe\u5ea6\u4e22\u6839\u56e0&#xff1b;\u8fd0\u7b97\u524d\u8f6c (float) \u6216\u4e58 1.0f\u3002<\/li>\n<li>\u53cd\u8fc7\u6765 float \u8f6c int \u4e22\u5c0f\u6570&#043;\u53ef\u80fd\u6ea2\u51fa\u2014\u2014\u5927 float \u8f6c int \u672a\u5b9a\u4e49&#xff1b;\u9700 lround\/\u8303\u56f4\u68c0\u67e5\u3002<\/li>\n<p>\u6b63\u786e\u89e3\u6cd5\u6d41\u7a0b\u5982\u4e0b&#xff1a;<\/p>\n<p>#mermaid-svg-776o700PMgFICs4N{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-776o700PMgFICs4N .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-776o700PMgFICs4N .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-776o700PMgFICs4N .error-icon{fill:#552222;}#mermaid-svg-776o700PMgFICs4N .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-776o700PMgFICs4N .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-776o700PMgFICs4N .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-776o700PMgFICs4N .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-776o700PMgFICs4N .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-776o700PMgFICs4N .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-776o700PMgFICs4N .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-776o700PMgFICs4N .marker{fill:#333333;stroke:#333333;}#mermaid-svg-776o700PMgFICs4N .marker.cross{stroke:#333333;}#mermaid-svg-776o700PMgFICs4N svg{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-776o700PMgFICs4N p{margin:0;}#mermaid-svg-776o700PMgFICs4N .label{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;color:#333;}#mermaid-svg-776o700PMgFICs4N .cluster-label text{fill:#333;}#mermaid-svg-776o700PMgFICs4N .cluster-label span{color:#333;}#mermaid-svg-776o700PMgFICs4N .cluster-label span p{background-color:transparent;}#mermaid-svg-776o700PMgFICs4N .label text,#mermaid-svg-776o700PMgFICs4N span{fill:#333;color:#333;}#mermaid-svg-776o700PMgFICs4N .node rect,#mermaid-svg-776o700PMgFICs4N .node circle,#mermaid-svg-776o700PMgFICs4N .node ellipse,#mermaid-svg-776o700PMgFICs4N .node polygon,#mermaid-svg-776o700PMgFICs4N .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-776o700PMgFICs4N .rough-node .label text,#mermaid-svg-776o700PMgFICs4N .node .label text,#mermaid-svg-776o700PMgFICs4N .image-shape .label,#mermaid-svg-776o700PMgFICs4N .icon-shape .label{text-anchor:middle;}#mermaid-svg-776o700PMgFICs4N .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-776o700PMgFICs4N .rough-node .label,#mermaid-svg-776o700PMgFICs4N .node .label,#mermaid-svg-776o700PMgFICs4N .image-shape .label,#mermaid-svg-776o700PMgFICs4N .icon-shape .label{text-align:center;}#mermaid-svg-776o700PMgFICs4N .node.clickable{cursor:pointer;}#mermaid-svg-776o700PMgFICs4N .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-776o700PMgFICs4N .arrowheadPath{fill:#333333;}#mermaid-svg-776o700PMgFICs4N .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-776o700PMgFICs4N .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-776o700PMgFICs4N .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-776o700PMgFICs4N .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-776o700PMgFICs4N .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-776o700PMgFICs4N .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-776o700PMgFICs4N .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-776o700PMgFICs4N .cluster text{fill:#333;}#mermaid-svg-776o700PMgFICs4N .cluster span{color:#333;}#mermaid-svg-776o700PMgFICs4N div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-776o700PMgFICs4N .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-776o700PMgFICs4N rect.text{fill:none;stroke-width:0;}#mermaid-svg-776o700PMgFICs4N .icon-shape,#mermaid-svg-776o700PMgFICs4N .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-776o700PMgFICs4N .icon-shape p,#mermaid-svg-776o700PMgFICs4N .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-776o700PMgFICs4N .icon-shape .label rect,#mermaid-svg-776o700PMgFICs4N .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-776o700PMgFICs4N .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-776o700PMgFICs4N .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-776o700PMgFICs4N :root{&#8211;mermaid-font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;}<span class=\"edgeLabel\"><\/span><span class=\"edgeLabel\"><\/span><span class=\"edgeLabel\"><\/p>\n<p>\u662f<\/p>\n<p><\/span><span class=\"edgeLabel\"><\/span><span class=\"edgeLabel\"><\/p>\n<p>\u5426<\/p>\n<p><\/span><span class=\"edgeLabel\"><\/span><span class=\"nodeLabel\"><\/p>\n<p>int raw &#061; 2000<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>(float)raw \/ 4095.0f<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>\u8fd0\u7b97\u524d\u5df2\u8f6c\u6d6e\u70b9?<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>\u6d6e\u70b9\u57df\u9664\u6cd5 \u4fdd\u7559\u5c0f\u6570<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>1.612V&#xff08;\u5bf9&#xff09;<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>\u6574\u6570\u9664\u6cd5 \u622a\u65ad<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>0.0V&#xff08;\u9519&#xff09;<\/p>\n<p><\/span><\/p>\n<h4>4.4 \u6539\u5b8c\u5bf9\u6bd4<\/h4>\n<table>\n<tr>\u6307\u6807\u6539\u524d\u6539\u540e<\/tr>\n<tbody>\n<tr>\n<td>raw&#061;2000 \u7535\u538b<\/td>\n<td>0.0V&#xff08;\u9519&#xff09;<\/td>\n<td>1.612V<\/td>\n<\/tr>\n<tr>\n<td>\u4e2d\u95f4\u503c\u7cbe\u5ea6<\/td>\n<td>\u4e22<\/td>\n<td>\u4fdd<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u4e94\u3001\u6536\u5c3e<\/h3>\n<p>\u8981\u70b9\u590d\u76d8<\/p>\n<li>int\/int \u662f\u6574\u6570\u9664\u6cd5&#xff08;\u622a\u65ad&#xff09;&#xff0c;\u518d\u8f6c float \u5df2\u665a&#xff0c;\u7cbe\u5ea6\u4e22\u5931\u3002<\/li>\n<li>\u6807\u5ea6\u6362\u7b97\u524d\u628a\u64cd\u4f5c\u6570\u8f6c\u6d6e\u70b9&#xff0c;\u6d6e\u70b9\u57df\u8fd0\u7b97\u4fdd\u7cbe\u5ea6\u3002<\/li>\n<li>float\u2192int \u53cd\u4e4b\u4e5f\u4e22\u5c0f\u6570\u4e14\u53ef\u80fd\u6ea2\u51fa&#xff0c;\u9700\u8c28\u614e\u3002<\/li>\n<p>\u6700\u4f73\u5b9e\u8df5\u6e05\u5355<\/p>\n<ul>\n<li>\u9664\u6cd5\u6807\u5ea6&#xff1a;\u7528 (float)a \/ b \u6216 *1.0f \u89e6\u53d1\u6d6e\u70b9\u9664\u6cd5\u3002<\/li>\n<li>\u660e\u786e\u6bcf\u6b65\u8fd0\u7b97\u7c7b\u578b&#xff0c;\u907f\u514d\u9690\u5f0f\u622a\u65ad\u3002<\/li>\n<li>\u5f00 -Wconversion \u6293\u9690\u5f0f\u7a84\u5316\u3002<\/li>\n<li>\u5927\u6570\u503c float\u2192int \u7528 lround &#043; \u8303\u56f4\u68c0\u67e5\u9632\u6ea2\u51fa\u3002<\/li>\n<li>\u5b9a\u70b9\u8fd0\u7b97&#xff08;Q \u683c\u5f0f&#xff09;\u53ef\u907f\u514d\u6d6e\u70b9\u5f00\u9500&#xff0c;\u9002\u5408\u65e0 FPU MCU\u3002<\/li>\n<\/ul>\n<p>\u8fdb\u9636\u5ef6\u4f38&#xff1a;\u65e0 FPU \u7684 MCU \u7528 Q \u683c\u5f0f\u5b9a\u70b9\u6570&#xff08;\u6574\u6570&#043;\u7f29\u653e\u56e0\u5b50&#xff09;\u66ff\u4ee3 float&#xff0c;\u65e2\u5feb\u53c8\u65e0\u7cbe\u5ea6\u622a\u65ad\u5751&#xff1b;\u6ce8\u610f Q \u683c\u5f0f\u4e58\u9664\u7684\u79fb\u4f4d\u3002<\/p>\n<p>\u4e92\u52a8&#xff1a;\u4f60\u7c7b\u578b\u8f6c\u6362\u8fd8\u8e29\u8fc7\u5565&#xff1f;uint8 \u8fd0\u7b97\u56de\u7ed5\u3001double \u622a\u65ad\u3001\u9690\u5f0f\u63d0\u5347&#xff08;\u7b2c42\u8bb2&#xff09;&#xff1f;\u8bc4\u8bba\u533a\u804a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7c7b\u578b\u8f6c\u6362\u7cbe\u5ea6\u4e22&#xff1a;int \u8f6c float \u622a\u65ad&#xff0c;\u5148\u8f6c\u5bbd\u7c7b\u578b\u518d\u7b97\u6458\u8981&#xff1a;\u672c\u6587\u901a\u8fc7\u4e00\u4e2a ADC \u6807\u5ea6\u6362\u7b97\u7ffb\u8f66\u6848\u4f8b&#xff0c;\u8bb2\u89e3 C \u8bed\u8a00\u4e2d int\/int \u6574\u6570\u9664\u6cd5\u622a\u65ad\u5bfc\u81f4\u7684\u7cbe\u5ea6\u4e22\u5931\u95ee\u9898\u3002\u6838\u5fc3\u539f\u56e0&#xff1a;\u4e24\u4e2a\u6574\u6570\u76f8\u9664\u7ed3\u679c\u4ecd\u662f\u6574\u6570&#xff0c;\u5c0f\u6570\u5728\u6574\u6570\u9636\u6bb5\u5df2\u88ab\u4e22\u5f03&#xff0c;\u518d\u8d4b\u7ed9 float \u4e3a\u65f6\u5df2\u665a\u3002\u89e3\u6cd5\u662f\u5728\u8fd0\u7b97\u524d\u628a\u64cd\u4f5c\u6570\u8f6c\u6210\u6d6e\u70b9&#xff08;(float)raw \/ 4095 \u6216\u4e58 1.0f&#xff09;&amp;#xf<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[7672,12136,5078,217,219],"topic":[],"class_list":["post-106827","post","type-post","status-publish","format-standard","hentry","category-server","tag-rtos","tag-12136","tag-freertos","tag-stm32","tag-219"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u7c7b\u578b\u8f6c\u6362\u7cbe\u5ea6\u4e22\uff1aint \u8f6c float \u622a\u65ad\uff0c\u5148\u8f6c\u5bbd\u7c7b\u578b\u518d\u7b97 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/106827.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u7c7b\u578b\u8f6c\u6362\u7cbe\u5ea6\u4e22\uff1aint \u8f6c float \u622a\u65ad\uff0c\u5148\u8f6c\u5bbd\u7c7b\u578b\u518d\u7b97 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u7c7b\u578b\u8f6c\u6362\u7cbe\u5ea6\u4e22&#xff1a;int \u8f6c float \u622a\u65ad&#xff0c;\u5148\u8f6c\u5bbd\u7c7b\u578b\u518d\u7b97\u6458\u8981&#xff1a;\u672c\u6587\u901a\u8fc7\u4e00\u4e2a ADC \u6807\u5ea6\u6362\u7b97\u7ffb\u8f66\u6848\u4f8b&#xff0c;\u8bb2\u89e3 C \u8bed\u8a00\u4e2d int\/int \u6574\u6570\u9664\u6cd5\u622a\u65ad\u5bfc\u81f4\u7684\u7cbe\u5ea6\u4e22\u5931\u95ee\u9898\u3002\u6838\u5fc3\u539f\u56e0&#xff1a;\u4e24\u4e2a\u6574\u6570\u76f8\u9664\u7ed3\u679c\u4ecd\u662f\u6574\u6570&#xff0c;\u5c0f\u6570\u5728\u6574\u6570\u9636\u6bb5\u5df2\u88ab\u4e22\u5f03&#xff0c;\u518d\u8d4b\u7ed9 float \u4e3a\u65f6\u5df2\u665a\u3002\u89e3\u6cd5\u662f\u5728\u8fd0\u7b97\u524d\u628a\u64cd\u4f5c\u6570\u8f6c\u6210\u6d6e\u70b9&#xff08;(float)raw \/ 4095 \u6216\u4e58 1.0f&#xff09;&amp;#xf\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/106827.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-18T03:48:52+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/106827.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/106827.html\",\"name\":\"\u7c7b\u578b\u8f6c\u6362\u7cbe\u5ea6\u4e22\uff1aint \u8f6c float \u622a\u65ad\uff0c\u5148\u8f6c\u5bbd\u7c7b\u578b\u518d\u7b97 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-18T03:48:52+00:00\",\"dateModified\":\"2026-09-18T03:48:52+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/106827.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/106827.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/106827.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u7c7b\u578b\u8f6c\u6362\u7cbe\u5ea6\u4e22\uff1aint \u8f6c float \u622a\u65ad\uff0c\u5148\u8f6c\u5bbd\u7c7b\u578b\u518d\u7b97\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u7c7b\u578b\u8f6c\u6362\u7cbe\u5ea6\u4e22\uff1aint \u8f6c float \u622a\u65ad\uff0c\u5148\u8f6c\u5bbd\u7c7b\u578b\u518d\u7b97 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/106827.html","og_locale":"zh_CN","og_type":"article","og_title":"\u7c7b\u578b\u8f6c\u6362\u7cbe\u5ea6\u4e22\uff1aint \u8f6c float \u622a\u65ad\uff0c\u5148\u8f6c\u5bbd\u7c7b\u578b\u518d\u7b97 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u7c7b\u578b\u8f6c\u6362\u7cbe\u5ea6\u4e22&#xff1a;int \u8f6c float \u622a\u65ad&#xff0c;\u5148\u8f6c\u5bbd\u7c7b\u578b\u518d\u7b97\u6458\u8981&#xff1a;\u672c\u6587\u901a\u8fc7\u4e00\u4e2a ADC \u6807\u5ea6\u6362\u7b97\u7ffb\u8f66\u6848\u4f8b&#xff0c;\u8bb2\u89e3 C \u8bed\u8a00\u4e2d int\/int \u6574\u6570\u9664\u6cd5\u622a\u65ad\u5bfc\u81f4\u7684\u7cbe\u5ea6\u4e22\u5931\u95ee\u9898\u3002\u6838\u5fc3\u539f\u56e0&#xff1a;\u4e24\u4e2a\u6574\u6570\u76f8\u9664\u7ed3\u679c\u4ecd\u662f\u6574\u6570&#xff0c;\u5c0f\u6570\u5728\u6574\u6570\u9636\u6bb5\u5df2\u88ab\u4e22\u5f03&#xff0c;\u518d\u8d4b\u7ed9 float \u4e3a\u65f6\u5df2\u665a\u3002\u89e3\u6cd5\u662f\u5728\u8fd0\u7b97\u524d\u628a\u64cd\u4f5c\u6570\u8f6c\u6210\u6d6e\u70b9&#xff08;(float)raw \/ 4095 \u6216\u4e58 1.0f&#xff09;&amp;#xf","og_url":"https:\/\/www.wsisp.com\/helps\/106827.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-18T03:48:52+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"9 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/106827.html","url":"https:\/\/www.wsisp.com\/helps\/106827.html","name":"\u7c7b\u578b\u8f6c\u6362\u7cbe\u5ea6\u4e22\uff1aint \u8f6c float \u622a\u65ad\uff0c\u5148\u8f6c\u5bbd\u7c7b\u578b\u518d\u7b97 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-18T03:48:52+00:00","dateModified":"2026-09-18T03:48:52+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/106827.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/106827.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/106827.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u7c7b\u578b\u8f6c\u6362\u7cbe\u5ea6\u4e22\uff1aint \u8f6c float \u622a\u65ad\uff0c\u5148\u8f6c\u5bbd\u7c7b\u578b\u518d\u7b97"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/106827","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=106827"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/106827\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=106827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=106827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=106827"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=106827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}