<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-CN">
		<id>http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Constrain%28%29</id>
		<title>Constrain() - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Constrain%28%29"/>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Constrain()&amp;action=history"/>
		<updated>2026-04-30T04:11:49Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=Constrain()&amp;diff=15798&amp;oldid=prev</id>
		<title>Pppeng：创建页面，内容为“&lt;pre style=&quot;color:green&quot;&gt; #define constrain(amt, low, high) ((amt)&lt;(low)?(low):((amt)&gt;(high)?(high):(amt))) &lt;/pre&gt; 调整到区间&lt;br&gt;  如果值 amt 小于 low, 则...”</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Constrain()&amp;diff=15798&amp;oldid=prev"/>
				<updated>2016-05-25T01:31:20Z</updated>
		
		<summary type="html">&lt;p&gt;创建页面，内容为“&amp;lt;pre style=&amp;quot;color:green&amp;quot;&amp;gt; #define constrain(amt, low, high) ((amt)&amp;lt;(low)?(low):((amt)&amp;gt;(high)?(high):(amt))) &amp;lt;/pre&amp;gt; 调整到区间&amp;lt;br&amp;gt;  如果值 amt 小于 low, 则...”&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;pre style=&amp;quot;color:green&amp;quot;&amp;gt;&lt;br /&gt;
#define constrain(amt, low, high) ((amt)&amp;lt;(low)?(low):((amt)&amp;gt;(high)?(high):(amt)))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
调整到区间&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
如果值 amt 小于 low, 则返回 low; 如果 amt 大于 high, 则返回 high; 否则, 返回 amt . 一般可以用于将值归一化到某个区间.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
例如:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:green&amp;quot;&amp;gt;&lt;br /&gt;
sensVal = constrain(sensVal, 10, 150);&lt;br /&gt;
// limits range of sensor values to between 10 and 150 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[https://www.microduino.cn/wiki/index.php/Arduino_%E8%AF%AD%E6%B3%95%E6%89%8B%E5%86%8C/zh 返回Arduino语法手册]]&lt;/div&gt;</summary>
		<author><name>Pppeng</name></author>	</entry>

	</feed>