Jon A. Lambert wrote:
> Are there predefined constants somewhere for these floating point values?
>
> => ["EPSILON", "MIN_10_EXP", "MANT_DIG", "MAX", "MAX_EXP", "RADIX", "MIN",
> "MIN_EXP", "ROUNDS", "MAX_10_EXP", "DIG"]
> irb(main):011:0> Math.constants
> => ["E", "PI"]
>
> irb(main):016:0> Float::MAX
> => 1.79769313486232e+308
> irb(main):017:0> Float::MIN
> => 2.2250738585072e-308
That's a vexing question 'cos you just gave a comprehensive list of them.
Perhaps numeric.c is the answer you wanted ?
> irb(main):009:0> (+1.0/0.0)
> => Infinity
> irb(main):012:0> (-1.0/0.0)
> => -Infinity
>
> irb(main):021:0> x = Inifinity
> NameError: uninitialized constant Inifinity
( In<i>finity spelling irrelevant )
Infinity is simulated all the way AFAICT - so, with your help,
I think this shows that your definition usably sticks:
negi = (-1.0/0.0)
p negi # -Infinity
Infinity = -negi
p Infinity # Infinity
p Infinity.class # Float
p Infinity == (+1.0/0.0)-1 # true
Without all that unnecessary fuss:
Infinity = (+1.0/0.0) # set constant
x = -Infinity-3
p x # -Infinity
daz
|