leon 1.0.9 → 1.1.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/lib/io.rb +6 -5
- metadata +1 -1
data/lib/io.rb
CHANGED
@@ -214,16 +214,17 @@ module LEON
|
|
214
214
|
return Constants::DOUBLE
|
215
215
|
elsif v.is_a? Float
|
216
216
|
v = v.abs
|
217
|
-
log = Math::log(v)/Math::log(2)
|
218
|
-
if log < -128 or log > 127
|
219
|
-
return Constants::DOUBLE
|
220
|
-
end
|
217
|
+
log = Math::log(v)/Math::log(2)
|
221
218
|
if log < 0
|
222
219
|
log = log.ceil
|
223
220
|
else
|
224
221
|
log = log.floor
|
225
222
|
end
|
226
|
-
|
223
|
+
exp = 103 + log
|
224
|
+
if exp < 0 or exp > 255
|
225
|
+
return Constants::DOUBLE
|
226
|
+
end
|
227
|
+
v *= 2**(-log + 24)
|
227
228
|
if v.floor != v
|
228
229
|
return Constants::DOUBLE
|
229
230
|
end
|