float-formats 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +27 -32
- data/Manifest.txt +10 -18
- data/README.txt +330 -327
- data/Rakefile +38 -4
- data/lib/float-formats.rb +9 -9
- data/lib/float-formats/bytes.rb +463 -303
- data/lib/float-formats/classes.rb +1950 -1605
- data/lib/float-formats/formats.rb +633 -669
- data/lib/float-formats/native.rb +144 -272
- data/lib/float-formats/version.rb +4 -4
- data/tasks/ann.rake +80 -0
- data/tasks/bones.rake +20 -0
- data/tasks/gem.rake +192 -0
- data/tasks/git.rake +40 -0
- data/tasks/manifest.rake +48 -0
- data/tasks/notes.rake +27 -0
- data/tasks/post_load.rake +39 -0
- data/tasks/rdoc.rake +50 -0
- data/tasks/rubyforge.rake +55 -0
- data/tasks/setup.rb +279 -0
- data/tasks/spec.rake +54 -0
- data/tasks/svn.rake +47 -0
- data/tasks/test.rake +40 -0
- data/test/gen_test_data.rb +119 -119
- data/test/test_arithmetic.rb +36 -0
- data/test/test_bytes.rb +43 -0
- data/test/test_data.yaml +1667 -1667
- data/test/test_float_formats.rb +208 -0
- data/test/test_helper.rb +2 -1
- data/test/test_native-float.rb +84 -77
- metadata +123 -60
- data/config/hoe.rb +0 -73
- data/config/requirements.rb +0 -17
- data/script/destroy +0 -14
- data/script/destroy.cmd +0 -1
- data/script/generate +0 -14
- data/script/generate.cmd +0 -1
- data/script/txt2html +0 -74
- data/script/txt2html.cmd +0 -1
- data/tasks/deployment.rake +0 -34
- data/tasks/environment.rake +0 -7
- data/tasks/website.rake +0 -17
- data/test/test_float-formats.rb +0 -169
@@ -0,0 +1,208 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
include Flt
|
5
|
+
|
6
|
+
class TestFloatFormats < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_nextprev
|
12
|
+
for tn in %w{IEEE_SINGLE IEEE_DOUBLE IEEE_EXTENDED IEEE_DEC32 IEEE_DEC64 IEEE_DEC128}
|
13
|
+
t = eval(tn)
|
14
|
+
z = t.from_text('0')
|
15
|
+
assert t.min_value.next_minus==z,"#{tn}: prv min == 0"
|
16
|
+
assert z.next_plus==t.min_value,"#{tn}: nxt 0 == min"
|
17
|
+
|
18
|
+
mz = t.from_text('-0')
|
19
|
+
assert t.min_value(-1).next_plus==mz,"#{tn}: nxt -min == -0"
|
20
|
+
assert mz.next_minus==t.min_value(-1),"#{tn}: prv -0 == -min"
|
21
|
+
|
22
|
+
assert z.next_minus==t.min_value(-1),"#{tn}: prv 0 == -min"
|
23
|
+
assert mz.next_plus==t.min_value,"#{tn}: nxt -0 == min"
|
24
|
+
end
|
25
|
+
|
26
|
+
for tn in %w{
|
27
|
+
APPLE XS128
|
28
|
+
BORLAND48
|
29
|
+
MBF_SINGLE MBF_DOUBLE
|
30
|
+
IEEE_SINGLE IEEE_DOUBLE IEEE_EXTENDED IEEE_128
|
31
|
+
IEEE_DEC32 IEEE_DEC64 IEEE_DEC128
|
32
|
+
XS256 XS256_DOUBLE
|
33
|
+
SATURN SATURN_X HP_CLASSIC
|
34
|
+
VAX_F VAX_D PDP11_F PDP11_D VAX_G VAX_H
|
35
|
+
IBM32 IBM64 IBM128 IBMX
|
36
|
+
CDC_SINGLE CDC_DOUBLE
|
37
|
+
CRAY
|
38
|
+
UNIVAC_SINGLE UNIVAC_DOUBLE
|
39
|
+
WANG2200
|
40
|
+
C51_BCD_FLOAT C51_BCD_DOUBLE C51_BCD_LONG_DOUBLE
|
41
|
+
}
|
42
|
+
t = eval(tn)
|
43
|
+
u = t.from_text('1')
|
44
|
+
mu = t.from_text('-1')
|
45
|
+
assert u.next_plus.minus == mu.next_minus,"#{tn}: -nxt 1 == prv -1"
|
46
|
+
assert mu.next_plus == u.next_minus.minus,"#{tn}: nxt -1 == -prv 1"
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
TEST_DATA = YAML.load(File.read(File.join(File.dirname(__FILE__),'test_data.yaml')))
|
53
|
+
|
54
|
+
|
55
|
+
def test_all
|
56
|
+
|
57
|
+
TEST_DATA.keys.each do |t|
|
58
|
+
|
59
|
+
flt = eval(t)
|
60
|
+
|
61
|
+
base = TEST_DATA[t]['base']
|
62
|
+
|
63
|
+
td = TEST_DATA[t]['parameters']
|
64
|
+
|
65
|
+
#puts "def test_#{t}_parameters"
|
66
|
+
for pair in td
|
67
|
+
attrb,v = pair.to_a.first
|
68
|
+
#puts " assert_equal #{v}, #{t}.#{attrb}"
|
69
|
+
assert_equal v, flt.send(attrb), "#{t}.#{attrb} == #{v}"
|
70
|
+
end
|
71
|
+
#puts "end"
|
72
|
+
|
73
|
+
|
74
|
+
td = TEST_DATA[t]['numerals']
|
75
|
+
#puts "def test_#{t}_numerals"
|
76
|
+
for pair in td
|
77
|
+
v,rep = pair.to_a.first
|
78
|
+
v_expr = "#{t}.from_text('#{v}')"
|
79
|
+
expr = base==:bytes ? "(#{v_expr}).to_hex(true)" : "(#{v_expr}).to_bits_text(#{base}).upcase"
|
80
|
+
#puts " assert_equal '#{rep}', #{expr}"
|
81
|
+
assert_equal rep, eval(expr), "#{expr} == '#{rep}'"
|
82
|
+
#puts "---"
|
83
|
+
end
|
84
|
+
#puts "end"
|
85
|
+
|
86
|
+
|
87
|
+
td = TEST_DATA[t]['special']
|
88
|
+
#puts "def test_#{t}_special"
|
89
|
+
for pair in td
|
90
|
+
v,rep = pair.to_a.first
|
91
|
+
#next if v=='epsilon'
|
92
|
+
v_expr = "#{t}.#{v}"
|
93
|
+
expr = base==:bytes ? "(#{v_expr}).to_hex(true)" : "(#{v_expr}).to_bits_text(#{base}).upcase"
|
94
|
+
assert_equal rep, eval(expr), "#{expr} == '#{rep}'"
|
95
|
+
end
|
96
|
+
#puts "end"
|
97
|
+
|
98
|
+
|
99
|
+
td = TEST_DATA[t]['values']
|
100
|
+
#puts "def test_#{t}_values"
|
101
|
+
for pair in td
|
102
|
+
v,rep = pair.to_a.first
|
103
|
+
v_expr = "#{t}.from_number(#{v})"
|
104
|
+
expr = base==:bytes ? "(#{v_expr}).to_hex(true)" : "(#{v_expr}).to_bits_text(#{base}).upcase"
|
105
|
+
assert_equal rep, eval(expr), "#{expr} == '#{rep}'"
|
106
|
+
end
|
107
|
+
#puts "end"
|
108
|
+
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
def test_hp71b
|
117
|
+
assert_equal(-499, HP71B.radix_min_exp)
|
118
|
+
assert_equal(499, HP71B.radix_max_exp)
|
119
|
+
|
120
|
+
fmt = Nio::Fmt.prec(12)
|
121
|
+
assert_equal '9.99999999999E499', HP71B.max_value.to_text(fmt)
|
122
|
+
assert_equal '0000000000001501', HP71B.min_value.to_bits_text(16)
|
123
|
+
assert_equal '1E-510', HP71B.min_value.to_text(fmt)
|
124
|
+
assert_equal '1E-499', HP71B.min_normalized_value.to_text(fmt)
|
125
|
+
|
126
|
+
assert_equal '9210000000000999',HP71B.from_text('-0.21').to_bits_text(16)
|
127
|
+
assert_equal '0100000000000001',HP71B.from_text('10').to_bits_text(16)
|
128
|
+
assert_equal '9000000000000000',HP71B.from_text('-0').to_bits_text(16)
|
129
|
+
assert_equal '0000510000000501', HP71B.from_text('0.0051E-499').to_bits_text(16)
|
130
|
+
|
131
|
+
assert_equal '0000000000000F01',HP71B.nan.to_bits_text(16).upcase
|
132
|
+
assert_equal 'NAN', HP71B.nan.to_text.upcase
|
133
|
+
assert_equal '0000000000000F00', HP71B.infinity.to_bits_text(16).upcase
|
134
|
+
assert_equal '+INFINITY', HP71B.infinity.to_text.upcase
|
135
|
+
assert_equal '9000000000000F00', HP71B.infinity.minus.to_bits_text(16).upcase
|
136
|
+
end
|
137
|
+
def test_quad
|
138
|
+
assert_equal "3fff 0000 0000 0000 0000 0000 0000 0000".tr(' ',''), IEEE_binary128_BE.from_text('1').to_hex.downcase
|
139
|
+
assert_equal "7ffe ffff ffff ffff ffff ffff ffff ffff".tr(' ',''), IEEE_binary128_BE.max_value.to_hex.downcase
|
140
|
+
assert_equal '1.19E4932', IEEE_binary128.max_value.to_text(Nio::Fmt.prec(4))
|
141
|
+
assert_equal "c000 0000 0000 0000 0000 0000 0000 0000".tr(' ',''), IEEE_binary128_BE.from_text('-2').to_hex.downcase
|
142
|
+
assert_equal "0000 0000 0000 0000 0000 0000 0000 0000".tr(' ',''), IEEE_binary128_BE.from_text('0').to_hex.downcase
|
143
|
+
assert_equal "8000 0000 0000 0000 0000 0000 0000 0000".tr(' ',''), IEEE_binary128_BE.from_text('-0').to_hex.downcase
|
144
|
+
assert_equal "7fff 0000 0000 0000 0000 0000 0000 0000".tr(' ',''), IEEE_binary128_BE.infinity.to_hex.downcase
|
145
|
+
assert_equal "ffff 0000 0000 0000 0000 0000 0000 0000".tr(' ',''), IEEE_binary128_BE.infinity(-1).to_hex.downcase
|
146
|
+
assert_equal "3ffd 5555 5555 5555 5555 5555 5555 5555".tr(' ',''), IEEE_binary128_BE.from_number(Rational(1,3)).to_hex.downcase
|
147
|
+
assert_equal "3fff 0000 0000 0000 0000 0000 0000 0001".tr(' ',''), IEEE_binary128_BE.from_text('1').next_plus.to_hex.downcase
|
148
|
+
end
|
149
|
+
def test_half
|
150
|
+
assert_equal "3c00", IEEE_binary16_BE.from_text('1').to_hex.downcase
|
151
|
+
assert_equal "7bff", IEEE_binary16_BE.max_value.to_hex.downcase
|
152
|
+
assert_equal '65504', IEEE_binary16_BE.max_value.to_text(Nio::Fmt.approx_mode(:exact))
|
153
|
+
assert_equal "0400", IEEE_binary16_BE.min_normalized_value.to_hex.downcase
|
154
|
+
assert_equal "6.103515625E-5", IEEE_binary16_BE.min_normalized_value.to_text(Nio::Fmt.approx_mode(:exact))
|
155
|
+
assert_equal "0001", IEEE_binary16_BE.min_value.to_hex.downcase
|
156
|
+
assert_equal "5.9604644775390625E-8", IEEE_binary16_BE.min_value.to_text(Nio::Fmt.approx_mode(:exact))
|
157
|
+
assert_equal "0000", IEEE_binary16_BE.from_text('0').to_hex.downcase
|
158
|
+
assert_equal "8000", IEEE_binary16_BE.from_text('-0').to_hex.downcase
|
159
|
+
assert_equal "7c00".tr(' ',''), IEEE_binary16_BE.infinity.to_hex.downcase
|
160
|
+
assert_equal "fc00".tr(' ',''), IEEE_binary16_BE.infinity(-1).to_hex.downcase
|
161
|
+
end
|
162
|
+
def test_special
|
163
|
+
assert_equal '+Infinity', IEEE_binary32.from_number(1.0/0.0).to_text
|
164
|
+
assert_equal '-Infinity', IEEE_binary32.from_number(-1.0/0.0).to_text
|
165
|
+
assert_equal '+Infinity', IEEE_binary32.from_text('+Infinity').to_text
|
166
|
+
assert_equal '-Infinity', IEEE_binary32.from_text('-Infinity').to_text
|
167
|
+
assert_equal 'NAN', IEEE_binary32.from_number(0.0/0.0).to_text.upcase
|
168
|
+
assert_equal 'NAN', IEEE_binary32.from_text('NaN').to_text.upcase
|
169
|
+
end
|
170
|
+
|
171
|
+
def test_double_double
|
172
|
+
|
173
|
+
assert_equal 128, IEEE_DOUBLE_DOUBLE.total_bits
|
174
|
+
assert_equal 16, IEEE_DOUBLE_DOUBLE.total_bytes
|
175
|
+
assert_equal 107, IEEE_DOUBLE_DOUBLE.significand_digits
|
176
|
+
assert_equal 31, IEEE_DOUBLE_DOUBLE.decimal_digits_stored
|
177
|
+
assert_equal 34, IEEE_DOUBLE_DOUBLE.decimal_digits_necessary
|
178
|
+
assert_equal 308, IEEE_DOUBLE_DOUBLE.decimal_max_exp
|
179
|
+
assert_equal(-307, IEEE_DOUBLE_DOUBLE.decimal_min_exp)
|
180
|
+
assert_equal 1023, IEEE_DOUBLE_DOUBLE.radix_max_exp
|
181
|
+
assert_equal(-1022, IEEE_DOUBLE_DOUBLE.radix_min_exp)
|
182
|
+
fmt = Nio::Fmt.prec(2).approx_mode(:exact).approx_mode(:exact)
|
183
|
+
assert_equal '1.8E308', IEEE_DOUBLE_DOUBLE.max_value.to_text(fmt)
|
184
|
+
assert_equal '2.2E-308', IEEE_DOUBLE_DOUBLE.min_normalized_value.to_text(fmt)
|
185
|
+
assert_equal '4.9E-324', IEEE_DOUBLE_DOUBLE.half.min_value.to_text(fmt)
|
186
|
+
|
187
|
+
assert_equal "0.5", IEEE_DOUBLE_DOUBLE('0.5').to_text
|
188
|
+
assert_equal "000000000000E03F0000000000000000", IEEE_DOUBLE_DOUBLE('0.5').to_hex
|
189
|
+
assert_equal "000000000000E03F0000000000004039", IEEE_DOUBLE_DOUBLE('0.5').next_plus.to_hex
|
190
|
+
assert_equal "9A9999999999B93F9A999999999959BC", IEEE_DOUBLE_DOUBLE('0.1').to_hex
|
191
|
+
assert_equal "9A9999999999B93F99999999999959BC", IEEE_DOUBLE_DOUBLE('0.1').next_plus.to_hex
|
192
|
+
|
193
|
+
assert_equal IEEE_DOUBLE_DOUBLE('0.5'), IEEE_DOUBLE_DOUBLE.join_halfs(*IEEE_DOUBLE_DOUBLE('0.5').split_halfs)
|
194
|
+
assert_equal IEEE_DOUBLE_DOUBLE('0.5').next_plus, IEEE_DOUBLE_DOUBLE.join_halfs(*IEEE_DOUBLE_DOUBLE('0.5').next_plus.split_halfs)
|
195
|
+
assert_equal IEEE_DOUBLE_DOUBLE('0.1'), IEEE_DOUBLE_DOUBLE.join_halfs(*IEEE_DOUBLE_DOUBLE('0.1').split_halfs)
|
196
|
+
assert_equal IEEE_DOUBLE_DOUBLE('0.1').next_plus, IEEE_DOUBLE_DOUBLE.join_halfs(*IEEE_DOUBLE_DOUBLE('0.1').next_plus.split_halfs)
|
197
|
+
|
198
|
+
assert_equal "00000000000050390000000000000000", IEEE_DOUBLE_DOUBLE.epsilon.to_hex
|
199
|
+
assert_equal "000000000000F87F0000000000000000", IEEE_DOUBLE_DOUBLE.nan.to_hex
|
200
|
+
assert_equal "NAN", IEEE_DOUBLE_DOUBLE.nan.to_text.upcase
|
201
|
+
assert_equal "000000000000F07F0000000000000000", IEEE_DOUBLE_DOUBLE.infinity.to_hex
|
202
|
+
assert_equal "+INFINITY", IEEE_DOUBLE_DOUBLE.infinity.to_text.upcase
|
203
|
+
assert_equal "00000000000000000000000000000000", IEEE_DOUBLE_DOUBLE.zero.to_hex
|
204
|
+
assert_equal "0", IEEE_DOUBLE_DOUBLE.zero.to_text.upcase
|
205
|
+
end
|
206
|
+
|
207
|
+
|
208
|
+
end
|
data/test/test_helper.rb
CHANGED
data/test/test_native-float.rb
CHANGED
@@ -1,77 +1,84 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
-
require File.dirname(__FILE__) + '/../lib/float-formats/native.rb'
|
3
|
-
require 'yaml'
|
4
|
-
|
5
|
-
require 'test/unit'
|
6
|
-
|
7
|
-
include
|
8
|
-
|
9
|
-
class TestNativeFloat < Test::Unit::TestCase
|
10
|
-
def test_nextprev
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
assert
|
15
|
-
|
16
|
-
assert(
|
17
|
-
assert(
|
18
|
-
|
19
|
-
assert((-
|
20
|
-
|
21
|
-
|
22
|
-
assert(-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
assert_equal
|
35
|
-
|
36
|
-
assert_equal
|
37
|
-
assert_equal(-1,
|
38
|
-
|
39
|
-
assert_equal
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
assert_equal
|
60
|
-
assert_equal
|
61
|
-
assert_equal
|
62
|
-
assert_equal
|
63
|
-
assert_equal
|
64
|
-
|
65
|
-
assert_equal
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
assert_equal
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
require File.dirname(__FILE__) + '/../lib/float-formats/native.rb'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
require 'test/unit'
|
6
|
+
|
7
|
+
include Flt
|
8
|
+
|
9
|
+
class TestNativeFloat < Test::Unit::TestCase
|
10
|
+
def test_nextprev
|
11
|
+
num_class = Float
|
12
|
+
context = num_class.context
|
13
|
+
|
14
|
+
assert context.next_minus(context.minimum_normal)==context.maximum_subnormal
|
15
|
+
assert context.minimum_normal==context.next_plus(context.maximum_subnormal)
|
16
|
+
assert context.next_minus(context.minimum_nonzero)==context.zero
|
17
|
+
assert context.minimum_nonzero==context.next_plus(context.zero)
|
18
|
+
|
19
|
+
assert(context.next_plus(-context.minimum_normal)==-context.maximum_subnormal)
|
20
|
+
assert(-context.next_minus(context.minimum_normal)==-context.maximum_subnormal)
|
21
|
+
assert(context.next_plus(-context.minimum_nonzero)==context.zero)
|
22
|
+
assert((-context.minimum_nonzero)==context.next_minus(context.zero))
|
23
|
+
|
24
|
+
|
25
|
+
assert(-(context.next_plus(1.0)) == context.next_minus(-1.0))
|
26
|
+
assert(context.next_plus(-1.0) == -(context.next_minus(1.0)))
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_hex
|
30
|
+
if Float::RADIX==2 && Float::MANT_DIG==53
|
31
|
+
assert_equal((1.0+Float::EPSILON),hex_to_float('0x1.0000000000001p0'))
|
32
|
+
assert_equal '0x10000000000001p-52', hex_from_float(1.0+Float::EPSILON)
|
33
|
+
end
|
34
|
+
assert_equal 1.0, hex_to_float(hex_from_float(1.0))
|
35
|
+
assert_equal(-1.0, hex_to_float(hex_from_float(-1.0)))
|
36
|
+
assert_equal 1.0e-5, hex_to_float(hex_from_float(1.0e-5))
|
37
|
+
assert_equal(-1.0e-5, hex_to_float(hex_from_float(-1.0e-5)))
|
38
|
+
|
39
|
+
assert_equal(+1,float_to_integral_sign_significand_exponent(+0.0).first)
|
40
|
+
assert_equal(-1,float_to_integral_sign_significand_exponent(-0.0).first)
|
41
|
+
assert_not_equal hex_from_float(-0.0), hex_from_float(+0.0)
|
42
|
+
assert_equal hex_to_float(hex_from_float(-0.0)), hex_to_float(hex_from_float(+0.0))
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def check_ulp_around(x)
|
48
|
+
context = Float.context
|
49
|
+
assert_equal x-context.next_minus(x), context.ulp(context.next_minus(x))
|
50
|
+
assert_equal x-context.next_minus(x), context.ulp(x)
|
51
|
+
assert_equal context.next_plus(x)-x, context.ulp(context.next_plus(x))
|
52
|
+
assert_equal context.next_plus(context.next_plus(x))-context.next_plus(x), context.ulp(context.next_plus(context.next_plus(x)))
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_ulp
|
56
|
+
num_class = Float
|
57
|
+
context = num_class.context
|
58
|
+
r = context.radix
|
59
|
+
assert_equal context.minimum_nonzero, context.ulp(context.zero)
|
60
|
+
assert_equal context.minimum_nonzero, context.ulp(context.minimum_nonzero)
|
61
|
+
assert_equal context.minimum_nonzero, context.ulp(context.next_plus(context.minimum_nonzero))
|
62
|
+
assert_equal context.minimum_nonzero, context.ulp((context.minimum_nonzero+context.maximum_subnormal)*0.5)
|
63
|
+
assert_equal context.minimum_nonzero, context.ulp(context.next_minus(context.maximum_subnormal))
|
64
|
+
assert_equal context.minimum_nonzero, context.ulp(context.maximum_subnormal)
|
65
|
+
assert_equal context.minimum_nonzero, context.ulp(context.minimum_normal)
|
66
|
+
assert_equal context.minimum_nonzero, context.ulp(context.next_plus(context.minimum_normal))
|
67
|
+
assert_equal context.minimum_nonzero, context.ulp(context.next_minus(context.minimum_normal*r))
|
68
|
+
assert_equal context.minimum_nonzero, context.ulp(context.minimum_normal*r)
|
69
|
+
assert_equal context.minimum_nonzero*r, context.ulp(context.next_plus((context.minimum_normal*r)))
|
70
|
+
check_ulp_around 1.0
|
71
|
+
assert_equal context.next_plus(1.0)-1.0, context.ulp(1.5)
|
72
|
+
check_ulp_around r.to_f
|
73
|
+
check_ulp_around Math.ldexp(1,10)
|
74
|
+
check_ulp_around Math.ldexp(1,-10)
|
75
|
+
check_ulp_around context.maximum_finite/r
|
76
|
+
assert_equal context.maximum_finite-context.next_minus(context.maximum_finite), context.ulp(context.next_minus(context.maximum_finite))
|
77
|
+
assert_equal context.maximum_finite-context.next_minus(context.maximum_finite), context.ulp(context.maximum_finite)
|
78
|
+
assert_equal context.maximum_finite-context.next_minus(context.maximum_finite), context.ulp(1.0/0.0)
|
79
|
+
assert(context.nan?(context.ulp(0.0/0.0)))
|
80
|
+
x = Math.ldexp(1,10)
|
81
|
+
assert_equal x-context.next_minus(x), context.ulp(context.next_minus(x))
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
metadata
CHANGED
@@ -1,87 +1,150 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.2
|
3
|
-
specification_version: 1
|
4
2
|
name: float-formats
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2007-12-15 00:00:00 +01:00
|
8
|
-
summary: Floating-Point Formats
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: javier@goizueta.info
|
12
|
-
homepage: http://float-formats.rubyforge.org
|
13
|
-
rubyforge_project: float-formats
|
14
|
-
description: Floating-Point Formats
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 0.2.0
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Javier Goizueta
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-08-06 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: flt
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.0.0
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: nio
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.2.4
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: nio
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.2.0
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: flt
|
47
|
+
type: :runtime
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.0.0
|
54
|
+
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bones
|
57
|
+
type: :development
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 2.1.1
|
64
|
+
version:
|
65
|
+
description: Floating-Point Formats
|
66
|
+
email: javier@goizueta.info
|
67
|
+
executables: []
|
68
|
+
|
69
|
+
extensions: []
|
70
|
+
|
71
|
+
extra_rdoc_files:
|
72
|
+
- History.txt
|
73
|
+
- License.txt
|
74
|
+
- README.txt
|
31
75
|
files:
|
32
76
|
- History.txt
|
33
77
|
- License.txt
|
34
78
|
- Manifest.txt
|
35
79
|
- README.txt
|
36
80
|
- Rakefile
|
37
|
-
- config/hoe.rb
|
38
|
-
- config/requirements.rb
|
39
81
|
- lib/float-formats.rb
|
40
|
-
- lib/float-formats/version.rb
|
41
82
|
- lib/float-formats/bytes.rb
|
42
83
|
- lib/float-formats/classes.rb
|
43
84
|
- lib/float-formats/formats.rb
|
44
85
|
- lib/float-formats/native.rb
|
45
|
-
-
|
46
|
-
- script/destroy.cmd
|
47
|
-
- script/generate
|
48
|
-
- script/generate.cmd
|
49
|
-
- script/txt2html
|
50
|
-
- script/txt2html.cmd
|
86
|
+
- lib/float-formats/version.rb
|
51
87
|
- setup.rb
|
52
|
-
- tasks/
|
53
|
-
- tasks/
|
54
|
-
- tasks/
|
55
|
-
-
|
56
|
-
-
|
57
|
-
-
|
88
|
+
- tasks/ann.rake
|
89
|
+
- tasks/bones.rake
|
90
|
+
- tasks/gem.rake
|
91
|
+
- tasks/git.rake
|
92
|
+
- tasks/manifest.rake
|
93
|
+
- tasks/notes.rake
|
94
|
+
- tasks/post_load.rake
|
95
|
+
- tasks/rdoc.rake
|
96
|
+
- tasks/rubyforge.rake
|
97
|
+
- tasks/setup.rb
|
98
|
+
- tasks/spec.rake
|
99
|
+
- tasks/svn.rake
|
100
|
+
- tasks/test.rake
|
58
101
|
- test/gen_test_data.rb
|
59
|
-
- test/
|
60
|
-
|
61
|
-
- test/
|
102
|
+
- test/test_arithmetic.rb
|
103
|
+
- test/test_bytes.rb
|
104
|
+
- test/test_data.yaml
|
105
|
+
- test/test_float_formats.rb
|
62
106
|
- test/test_helper.rb
|
63
107
|
- test/test_native-float.rb
|
108
|
+
has_rdoc: true
|
109
|
+
homepage: http://float-formats.rubyforge.org
|
110
|
+
licenses: []
|
111
|
+
|
112
|
+
post_install_message:
|
64
113
|
rdoc_options:
|
65
114
|
- --main
|
66
115
|
- README.txt
|
67
|
-
|
68
|
-
-
|
69
|
-
-
|
70
|
-
-
|
116
|
+
- --title
|
117
|
+
- Float-Formats Documentation
|
118
|
+
- --opname
|
119
|
+
- index.html
|
120
|
+
- --line-numbers
|
121
|
+
- --inline-source
|
122
|
+
- --main
|
71
123
|
- README.txt
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: "0"
|
131
|
+
version:
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: "0"
|
137
|
+
version:
|
76
138
|
requirements: []
|
77
139
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
140
|
+
rubyforge_project: float-formats
|
141
|
+
rubygems_version: 1.3.3
|
142
|
+
signing_key:
|
143
|
+
specification_version: 3
|
144
|
+
summary: Floating-Point Formats
|
145
|
+
test_files:
|
146
|
+
- test/test_arithmetic.rb
|
147
|
+
- test/test_bytes.rb
|
148
|
+
- test/test_float_formats.rb
|
149
|
+
- test/test_helper.rb
|
150
|
+
- test/test_native-float.rb
|