I m 撰写一些关于Arduino的法典,该法典需要迅速运行,并对 in化的百分比进行粗略估计。
例如,鉴于我想要找到其中90%,即70%或30%。 这样做的明显方法是用浮动点g. x * 0.9;或x * 0.3;但由于我需要速度,我想避免计算浮动点。 如果我只是用两种力量分裂,那么我就进行双向转变,但是否有类似的技术可以接近90%、80%等使用惯犯?
I m 撰写一些关于Arduino的法典,该法典需要迅速运行,并对 in化的百分比进行粗略估计。
例如,鉴于我想要找到其中90%,即70%或30%。 这样做的明显方法是用浮动点g. x * 0.9;或x * 0.3;但由于我需要速度,我想避免计算浮动点。 如果我只是用两种力量分裂,那么我就进行双向转变,但是否有类似的技术可以接近90%、80%等使用惯犯?
你们可以把拥有二分母权力的分数计算出这些百分比。
下面是<代码>2^16的简单例子:
90% = 90 / 100 ~ 58982 / 65536
70% = 70 / 100 ~ 45875 / 65536
30% = 30 / 100 ~ 19661 / 65536
x% = x / 100 ~ x * 655 / 65536
各司(现为两权)可以轮流进行。
当然,可以进行一些预先计算,以产生这些分数。
Bi ANG 我怎么能够只利用轨道变化和增加而成倍和分裂?
您可使用比值转换成倍数和分数轴例x = (x*9)/10
As for a code example, if you get stuck I could try and burn some brain cells to work it out. Just ask :)
What to look for in performance analyzer in VS 2008 I am using VS Team system and got the performance wizard and reports going. What benchmarks/process do I use? There is a lot of stuff in the ...
We have a number of items coming in from a web service; each item containing an unknown number of properties. We are storing them in a database with the following Schema. Items - ItemID - ...
Are there some noticeable outcomes in terms of performance or other aspects to follow semantic HTML?
I m using Visual Studio 2008 (with the latest service pack) I also have ReSharper 4.5 installed. ReSharper Code analysis/ scan is turned off. OS: Windows 7 Enterprise Edition It takes me a long time ...
As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...
I ve tried searching for this but it s pretty difficult to put into words. Basically, our site will run fine for most users without any issues. Sometimes though, those of us who use the site pretty ...
Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...
So I m running perl 5.10 on a core 2 duo macbook pro compiled with threading support: usethreads=define, useithreads=define. I ve got a simple script to read 4 gzipped files containing aroud 750000 ...