如何检查是否一个数是另外两个数字之间的ActionScript 3的? [英] How to check if a number is between two other numbers in Actionscript 3?

查看:120
本文介绍了如何检查是否一个数是另外两个数字之间的ActionScript 3的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能检查一个数字是其他两个数字之间,如:

How can i check if a number is between two other numbers like:

伪code:

var = 458;

if (var is between 0 and 1000) give positive.

if (var is between 1001 and 2000) give negative.

if (var is between 2001 and 3000) give negative.

在AS3?

在此先感谢。

推荐答案

如果您将检查过很多次,只需创建功能:

If You will check it many times, simply create function :

function check(min:Number , value:Number , max:Number):Boolean{
    return min > value ? false : ( max < value ? false : true );
}

这将返回true,如果值的最小值和最大值之间。

It will return true if value is between min and max.

这篇关于如何检查是否一个数是另外两个数字之间的ActionScript 3的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆