Best name for a "non-negative" value?

I check that the integer is zero or more. Describing the requirement as “zero or more” seems too verbose. Saying “non-negative” introduces a negative language, which I try to avoid when I can.

Which compressed descriptor do you use when describing a value that should be zero or more?

+3
source share
11 answers

I would say that the answer depends on what audience you write to. If this is for other developers (i.e. for variable names or API documents), then I think that "non-negative" most accurately expresses what you want. If this is for end-user documentation, then “positive” will be ok.

Always consider your audience even while programming.

+3
source

positiveValue or unsignedValue

If you use unsignedValueas a name, you must also make sure that you are using the appropriate type of unsigned data (if your language supports it). If you use the correct data type, you will not need to check anything ... the type will do this for you.

+7
source

. , , .

, , . , . , , . , .

// . 3 : , . , , , . .

+5

+3

. , ;)

, " X", , (, " " ).

+2

Positive. , , .

Unsigned - , (Ok, , )

+1


, naturals;)

+1

- :

" "

:

" "

+1

+1

" ". () , . " " ( , ). "" .

0

An unsigned will be incorrect, as it refers to a variable that can only be positive. I believe that the correct name for this will be positive.

-2
source

Source: https://habr.com/ru/post/1765998/


All Articles