Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the minimum value of int 1 farther from zero than the positive value?

I want to know why int, double etc have 1 more negative value than positive value.

like image 393
sumit sharma Avatar asked Jan 12 '13 07:01

sumit sharma


People also ask

What is integer minimum value?

The Integer. MIN_VALUE is a constant in the Integer class that represents the minimum or least integer value that can be represented in 32 bits, which is -2147483648, -231.

How do you find the maximum or minimum value?

We will set the first derivative of the function to zero and solve for x to get the critical point. If we take the second derivative or f''(x), then we can find out whether this point will be a maximum or minimum. If the second derivative is positive, it will be a minimum value.

How do you find the minimum value?

You can find this minimum value by graphing the function or by using one of the two equations. If you have the equation in the form of y = ax^2 + bx + c, then you can find the minimum value using the equation min = c - b^2/4a.

Why do we use integer MAX_VALUE?

MAX_VALUE in Java Required? It is used to automatically assign any variable the maximum integer possible without requiring to remember the exact number. There are many times when we need a maximum or minimum number.


1 Answers

In a nutshell: 0 has to fit somewhere, it is in the positives, which makes them have one less than the negatives.

Example: 5 slots for negatives and 5 for positives, negatives get -1 to -5, positives get 0 to 4

  • don't forget to read @chris link :)

As @WhozCraig pointed out, this is only valid for architectures that use two's complement representation of signed binary numbers.

like image 117
Arnaud Avatar answered Oct 31 '22 18:10

Arnaud