blob: 497e0ae18846a97cf825d441bdf8f683aa25a75f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
require_relative '../../spec_helper'
describe "Float constant" do
it "DIG is 15" do
Float::DIG.should == 15
end
it "EPSILON is 2.220446049250313e-16" do
Float::EPSILON.should == 2.0 ** -52
Float::EPSILON.should == 2.220446049250313e-16
end
it "MANT_DIG is 53" do
Float::MANT_DIG.should == 53
end
it "MAX_10_EXP is 308" do
Float::MAX_10_EXP.should == 308
end
it "MIN_10_EXP is -308" do
Float::MIN_10_EXP.should == -307
end
it "MAX_EXP is 1024" do
Float::MAX_EXP.should == 1024
end
it "MIN_EXP is -1021" do
Float::MIN_EXP.should == -1021
end
it "MAX is 1.7976931348623157e+308" do
# See https://en.wikipedia.org/wiki/Double-precision_floating-point_format#Double-precision_examples
Float::MAX.should == (1 + (1 - (2 ** -52))) * (2.0 ** 1023)
Float::MAX.should == 1.7976931348623157e+308
end
it "MIN is 2.2250738585072014e-308" do
Float::MIN.should == (2.0 ** -1022)
Float::MIN.should == 2.2250738585072014e-308
end
it "RADIX is 2" do
Float::RADIX.should == 2
end
it "INFINITY is the positive infinity" do
Float::INFINITY.infinite?.should == 1
end
it "NAN is 'not a number'" do
Float::NAN.nan?.should be_true
end
end
|