“独占”的含义是什么?和“包容”描述数字范围时? [英] What is the meaning of "exclusive" and "inclusive" when describing number ranges?

查看:129
本文介绍了“独占”的含义是什么?和“包容”描述数字范围时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个简单的问题,但是当我提到数字范围时,我会看到互斥和包容。

Simple question but, I see exclusive and inclusive when referring to number ranges.

例如,这是一本算法书中的一行:

For example, this is a line from an algorithms book:


以下函数从1到n(包括2)打印2的幂。

The following function prints the powers of 2 from 1 through n (inclusive).

这是什么意思?是什么使数字范围包含或不包含?

What is meant by this? What makes a number range inclusive or exclusive?

推荐答案


以下函数从以下位置打印2的幂1到n(含1)。

The following function prints the powers of 2 from 1 through n (inclusive).

这意味着该函数将计算 2 ^ i 其中 i = 1,2,...,n ,换句话说, i 可以具有值从1到并包括 n 。即n是 包含的 包含

This means that the function will compute 2^i where i = 1, 2, ..., n, in other words, i can have values from 1 up to and including the value n. i.e n is Included in Inclusive

如果,另一方面,您的书说过:

If, on the other hand, your book had said:


以下函数从1到n打印2的幂( )。

这意味着 i = 1,2,...,n -1 ,即 i 最多可以取n-1,但包括 n ,这意味着 i = n-1 是它可能具有的最大值。即n被排除在 之外 中的

This would mean that i = 1, 2, ..., n-1, i.e. i can take values up to n-1, but not including, n, which means i = n-1 is the highest value it could have.i.e n is excluded in exclusive.

这篇关于“独占”的含义是什么?和“包容”描述数字范围时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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