Harsh - 1 year ago 89

Ruby Question

Java has a constant

`Integer.MIN_VALUE`

Is there any equivalent code to

Answer Source

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