Harsh - 10 months ago 59

Ruby Question

Java has a constant

`Integer.MIN_VALUE`

Is there any equivalent code to

Answer

Ruby automatically "upgrades" the number (FixNumb -> BigNum) to hold the value provided, but the minimal value before the upgrade is:

```
FIXNUM_MIN = -(2**(0.size * 8 -2))
```

`0.size`

gives the number of bytes used to store the number, so we need to multiply it by 8, to get bits and substract 2 bits.

2 bits is for:

- one bit for sign
- one bit for marking the number as integer