Project

General

Profile

Actions

Backport #1397

closed

to_f of rational

Added by bk1 (Karl Brodowsky) about 15 years ago. Updated about 13 years ago.

Status:
Closed

Description

=begin
irb
irb(main):001:0> require "rational"
=> true
irb(main):002:0> a=10**309
=> 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
irb(main):003:0> b=a+1
=> 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
irb(main):004:0> c=Rational(a,b)
=> Rational(1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001)
irb(main):005:0> c.to_f
/usr/local/lib/ruby/1.8/rational.rb:390: warning: Bignum out of Float range
/usr/local/lib/ruby/1.8/rational.rb:390: warning: Bignum out of Float range
=> NaN
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0