• Serdan@lemm.ee
    link
    fedilink
    English
    arrow-up
    55
    ·
    10 months ago

    Negative integers are also whole.

    You may be thinking of “natural numbers”, and the reason is that there’s no universal rule on whether to include zero or not.

  • Fondots@lemmy.world
    link
    fedilink
    English
    arrow-up
    27
    ·
    edit-2
    10 months ago

    An “integer” is a whole number- a number that isn’t a fraction/decimal. You can have negative integers/whole numbers, and 0 is also an integer that isn’t truly positive or negative.

    If you specify that you want a positive whole number/integer that technically wouldn’t include 0, same if you specify a negative number.

    So if you’re looking for a value that is a whole number that is either zero or positive “non-negative integer” is probably the most succinct way to phrase it.

    They can also be called “natural numbers” but depending on context, that may not always include 0.

  • motsu@lemmy.world
    link
    fedilink
    English
    arrow-up
    4
    arrow-down
    4
    ·
    10 months ago

    Can you give more context to where the phrasing is used? Coming from a computer science angle, there are different data types for different things. For instance, you would use a “float” (floating point) data type to store a number like 7.12. Likewise, you use an “int” to store a whole number (such as 7). Because computers use a certain number of bits to store information, this means there’s a max size to your data. int data types specifically have a “signed int” option as well as an “unsigned int” (the latter being a non negative integer). The benefit there is that by not storing a sign, the int can store numbers about 2x as large as a signed int.

    If I dont need to ever store a negative value, I might explicitly call out that when writing out an algorithm