Float::MIN Not an actual minimum?

I was curious as to why it would be possible to perform operations that
did
not result in zero, on a number smaller than Float::MIN. To me
Float::MIN
should be the smallest representable number that is not 0, yet on my
system
at least, I can perform valid operations on numbers smaller than
Float::MIN.
Is this a system dependent thing? Granted I can’t actually create the
number
by going ‘f = 4.94065645841247e-324’ as I get a ‘Float
4.94065645841247e-324out of range’ warning, and the only way to create
numbers smaller than
Float::MIN is to either unpack a binary representation of a smaller
number,
or divide Float::MIN by some number, but I think that is because of
checks
in the source checking the exponent or something.

It just had me curious as to if this is something people are aware of,
and
if there is some reason for it.

unpacked = “\0\0\0\0\0\0\0\1”.unpack(‘G’).first
smallish = Float::MIN / 100000000000000
smallest = Float::MIN / 3002399751580330.75 # (Smallest divisor that
will
result in a double value of 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01)
toosmall = Float::MIN / 9007199254740991.5 # (Smallest divisor that will
result in a double value of 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00)
floatmin = Float::MIN
puts 'Unpacked: ’ << unpacked.to_s << ’ class: ’ << unpacked.class.to_s
<< ’
Finite: ’ << unpacked.finite?.to_s << ’ Nan: ’ << unpacked.nan?.to_s
puts 'Smallish: ’ << smallish.to_s << ’ class: ’ << smallish.class.to_s
<< ’
Finite: ’ << smallish.finite?.to_s << ’ Nan: ’ << smallish.nan?.to_s
puts 'Smallest: ’ << smallest.to_s << ’ class: ’ << smallest.class.to_s
<< ’
Finite: ’ << smallest.finite?.to_s << ’ Nan: ’ << smallest.nan?.to_s
puts 'TooSmall: ’ << toosmall.to_s << ’ class: ’ << toosmall.class.to_s
<< ’
Finite: ’ << toosmall.finite?.to_s << ’ Nan: ’ << toosmall.nan?.to_s
puts 'Floatmin: ’ << floatmin.to_s << ’ class: ’ << floatmin.class.to_s
<< ’
Finite: ’ << floatmin.finite?.to_s << ’ Nan: ’ << floatmin.nan?.to_s

puts (smallest == unpacked).to_s
puts (unpacked < Float::MIN && smallest < Float::MIN && smallish <
Float::MIN).to_s
puts (smallish - unpacked).to_s
puts (smallish - smallest).to_s
puts (smallish - toosmall).to_s
puts (unpacked - smallish).to_s
puts (smallest - smallish).to_s
puts (toosmall - smallish).to_s

puts (9007199254740991.5 - 3002399751580330.75)

====================

Unpacked: 4.94065645841247e-324 class: Float Finite: true Nan: false
Smallish: 2.22329540628561e-322 class: Float Finite: true Nan: false
Smallest: 4.94065645841247e-324 class: Float Finite: true Nan: false
TooSmall: 0.0 class: Float Finite: true Nan: false
Floatmin: 2.2250738585072e-308 class: Float Finite: true Nan: false
true
true
2.17388884170148e-322
2.17388884170148e-322
2.22329540628561e-322
-2.17388884170148e-322
-2.17388884170148e-322
-2.22329540628561e-322
6.00479950316066e+15

“Every child has many wishes. Some include a wallet, two chicks and a
cigar,
but that’s another story.”

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs