Project

General

Profile

Actions

Bug #13134

closed

Rational() inconsistency

Added by nobu (Nobuyoshi Nakada) almost 8 years ago. Updated over 7 years ago.

Status:
Closed
Target version:
-
[ruby-core:79104]

Description

Rational() parses a float, an integer divided by an integer, and a float divided by an integer.

Rational("3.1")     #=> (31/10)
Rational("3/2")     #=> (3/2)
Rational("3.1/2")   #=> (31/20)

But a float is not allowed as a denominator.

Rational("3.1/2.0") #=> ArgumentError

I'd expect the last also passes and results in (31/20), or the third also raises an ArgumentError

A patch to let all pass.
https://github.com/ruby/ruby/compare/trunk...nobu:parse_rat

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0