在C中具有min和max之间的值? [英] Having the value between min and max in C?
本文介绍了在C中具有min和max之间的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
i有代码可以给我一些风扇的最大和最小速度,但是当我用这个代码时,速度可以超过最大值,例如:最大值为100,速度为110.
所以我需要让速度在最大值和最小值之间移动。
< b>我尝试过的事情:
i have code which ginves me the max and min of the speed of some fan , but when i ruf this code the speed can go more than max , for example : the max is 100 , and the speed is 110.
so i need to let the speed moves between max and min .
What I have tried:
senveolp_ret.Max_sp = interpolate_2k(poly_test[i].Max_sp , closetPolygon.Max_sp, distance);
senveolp_ret.Min_sp = interpolate_2k(poly_test[i].Min_sp , closetPolygon.Min_sp, distance);
//她得到max和min
// her i get max and min
推荐答案
所以出了点问题 - 但是什么?也许你的粉丝需要很快的速度或代码中的一些错误。首先:检查输入并提供一些修复日志。
我会在代码中搜索一个好位置并通过提供一些输出来这样写/>
So something is wrong - but what? Maybe your fan has to much speed or some bug in your code. At first: check the input and provide some logging with a fix.
I would search a good place in the code and write it this way by providing some output
//HACK: limiting the speed
if( speed > 100 ) {
printf("speed %ld is too high. Settting max to 100", speed );
speed = 100;
}
不过你应该找到问题的真正原因。
Nevertheless you should find the real cause of your issue.
这篇关于在C中具有min和max之间的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文