Skip to main content
deleted 638 characters in body
Source Link
SuperNovaCoder
  • 810
  • 1
  • 8
  • 25

EDIT:

Let's look at while(n <= 0) and while(n < 1). These are essentially the same, because both excludecheck for 0 and negative numbers. n <= 0 simply specifies to check if n is less than or equal to 0., while n < 1 states to checkchecks if n is less than 1, which includes 0 and negative numbers. As you can see, they are essentially the same.

However, if it was n >= 0 and n > 1, these would be different. In n >= 0, it is checking if n is greater than or equal to 0. This includes 0, 1, 2, 3, and so on. In n > 1, it checks if n is greater than 1. This includes 2, 3, 4, and so on, but NOTnot 0 or 1. Basically, theThe difference is that n >= 0 includes 0 and 1 while n > 1 doesn't.

Now, why are only (as you said in your comment) n >= 0 and (as CliffB said) n <= 0 valid for floats? In n >= 0, numbers like 0.1, 0.2, 0.3, and so on count because these numbers are, in fact, greater than 0. But in n > 1, numbers like 0.1, 0.2, 0.3, and so on will NOT count because these numbers are not greater than 1. The same goes for n <= 0 - numbers like -0.1, -0.2, and -0.3 will count because these are less than 0, while if you use n < 1, these numbers will not count because they aren't less than 1.

If you still have issues/questions, comment below. :-)

EDIT:

Let's look at while(n <= 0) and while(n < 1). These are the same, because both exclude 0 and negative numbers. n <= 0 simply specifies to check if n is less than or equal to 0. n < 1 states to check if n is less than 1, which includes 0 and negative numbers. As you can see, they are essentially the same.

However, if it was n >= 0 and n > 1, these would be different. In n >= 0, it is checking if n is greater than or equal to 0. This includes 0, 1, 2, 3, and so on. In n > 1, it checks if n is greater than 1. This includes 2, 3, 4, and so on, but NOT 0 or 1. Basically, the difference is that n >= 0 includes 0 and 1 while n > 1 doesn't.

Now, why are only (as you said in your comment) n >= 0 and (as CliffB said) n <= 0 valid for floats? In n >= 0, numbers like 0.1, 0.2, 0.3, and so on count because these numbers are, in fact, greater than 0. But in n > 1, numbers like 0.1, 0.2, 0.3, and so on will NOT count because these numbers are not greater than 1. The same goes for n <= 0 - numbers like -0.1, -0.2, and -0.3 will count because these are less than 0, while if you use n < 1, these numbers will not count because they aren't less than 1.

If you still have issues/questions, comment below. :-)

Let's look at while(n <= 0) and while(n < 1). These are essentially the same, because both check for 0 and negative numbers. n <= 0 simply specifies to check if n is less than or equal to 0, while n < 1 checks if n is less than 1.

However, if it was n >= 0 and n > 1, these would be different. In n >= 0, it is checking if n is greater than or equal to 0. This includes 0, 1, 2, 3, and so on. In n > 1, it checks if n is greater than 1. This includes 2, 3, 4, and so on, but not 0 or 1. The difference is that n >= 0 includes 0 and 1 while n > 1 doesn't.

If you still have issues/questions, comment below.

deleted 63 characters in body
Source Link
SuperNovaCoder
  • 810
  • 1
  • 8
  • 25

If this answers your question, please hit the green checkmark. If you still have issues/questions, comment below. :-)

If this answers your question, please hit the green checkmark. If you still have issues/questions, comment below. :-)

If you still have issues/questions, comment below. :-)

added 1215 characters in body
Source Link
SuperNovaCoder
  • 810
  • 1
  • 8
  • 25

EDIT:

Let's look at while(n <= 0) and while(n < 1). These are the same, because both exclude 0 and negative numbers. n <= 0 simply specifies to check if n is less than or equal to 0. n < 1 states to check if n is less than 1, which includes 0 and negative numbers. As you can see, they are essentially the same.

However, if it was n >= 0 and n > 1, these would be different. In n >= 0, it is checking if n is greater than or equal to 0. This includes 0, 1, 2, 3, and so on. In n > 1, it checks if n is greater than 1. This includes 2, 3, 4, and so on, but NOT 0 or 1. Basically, the difference is that n >= 0 includes 0 and 1 while n > 1 doesn't.

Now, why are only (as you said in your comment) n >= 0 and (as CliffB said) n <= 0 valid for floats? In n >= 0, numbers like 0.1, 0.2, 0.3, and so on count because these numbers are, in fact, greater than 0. But in n > 1, numbers like 0.1, 0.2, 0.3, and so on will NOT count because these numbers are not greater than 1. The same goes for n <= 0 - numbers like -0.1, -0.2, and -0.3 will count because these are less than 0, while if you use n < 1, these numbers will not count because they aren't less than 1.

If this answers your question, please hit the green checkmark. If you still have issues/questions, comment below. :-)

If this answers your question, please hit the green checkmark. If you still have issues/questions, comment below. :-)

EDIT:

Let's look at while(n <= 0) and while(n < 1). These are the same, because both exclude 0 and negative numbers. n <= 0 simply specifies to check if n is less than or equal to 0. n < 1 states to check if n is less than 1, which includes 0 and negative numbers. As you can see, they are essentially the same.

However, if it was n >= 0 and n > 1, these would be different. In n >= 0, it is checking if n is greater than or equal to 0. This includes 0, 1, 2, 3, and so on. In n > 1, it checks if n is greater than 1. This includes 2, 3, 4, and so on, but NOT 0 or 1. Basically, the difference is that n >= 0 includes 0 and 1 while n > 1 doesn't.

Now, why are only (as you said in your comment) n >= 0 and (as CliffB said) n <= 0 valid for floats? In n >= 0, numbers like 0.1, 0.2, 0.3, and so on count because these numbers are, in fact, greater than 0. But in n > 1, numbers like 0.1, 0.2, 0.3, and so on will NOT count because these numbers are not greater than 1. The same goes for n <= 0 - numbers like -0.1, -0.2, and -0.3 will count because these are less than 0, while if you use n < 1, these numbers will not count because they aren't less than 1.

If this answers your question, please hit the green checkmark. If you still have issues/questions, comment below. :-)

added 270 characters in body
Source Link
SuperNovaCoder
  • 810
  • 1
  • 8
  • 25
Loading
Source Link
SuperNovaCoder
  • 810
  • 1
  • 8
  • 25
Loading