Project

General

Profile

Actions

Backport #3550

closed

Floating Point Representation Prevents Raising to Fractional Power

Added by mspandit (Milind Pandit) over 14 years ago. Updated over 5 years ago.

Status:
Closed
Assignee:
-
[ruby-core:31121]

Description

=begin
Not sure why this literal float can be raised successfully to a fractional power, but when assigned to a variable, it returns NaN.

$ ruby --version
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
$ irb
-2.21792114695341 ** 0.1
=> -1.08291560040828

-2.21792114695341 ** 1.1
=> -2.40182141051126
a = -2.21792114695341
=> -2.21792114695341
a ** 0.1
=> NaN # Expected: -1.08291560040828
a ** 1.1
=> NaN # Expected: -2.40182141051126
-2.21792114695341.to_f ** 1.1
=> NaN # Expected: -1.08291560040828
-2.21792114695341.to_f ** 0.1
=> NaN # Expected: -2.40182141051126
a - -2.21792114695341
=> 0.0
(a - -2.21792114695341).zero?
=> true
=end


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #3746: Incorrect Float subtractionRejected08/26/2010Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0