[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: why Float::MIN? is positive

Williams, Chris

3/28/2005 8:56:00 PM

> Sorry for typo in previouse post:
> Shouldn't Float::MIN = -Float::MAX
>

Not necessarily. Typically when you have signed numeric integers the
absolute values of max and min are one off. You need to "use" a bit to
represent 0. That zero gets counted against either the positive or
negative end. The other end gets to represent at least one "additional"
value then. Usually in a sane way, zero is "counted against" the
positive end.

Break the representations down into individual bits to see. If we have
two bits, we can represent four values. If we want one of those to be a
sign bit, then we can have:

00 => 0
01 => +1
10 => -1 (since we already have zero)
11 => -2

So our max is 1, while our min is -2.

Thanks,
Chris