Project

General

Profile

Actions

Bug #18188

closed

-1 ** 0 is 1 not -1

Added by r.burrowes@auckland.ac.nz (Robert Burrowes) about 3 years ago. Updated about 3 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-freebsd11.2]
[ruby-core:105387]

Description

Any negative number to the power of 0 is 1, but ruby is returning -1.

i.e. it should be n == 0 ? 1 : x ** n

/usr/local/ruby3.0/bin/ruby
puts -1**0
-1


Related issues 2 (0 open2 closed)

Is duplicate of Ruby master - Bug #13152: Numeric parsing differences between ruby <-> crystalRejectedActions
Is duplicate of Ruby master - Bug #16677: Negative integer powered (**) to a float number results in a complex Closedmatz (Yukihiro Matsumoto)Actions

Updated by jeremyevans0 (Jeremy Evans) about 3 years ago

  • Status changed from Open to Rejected

-1**0 is parsed as -(1**0), not (-1)**0. (-1)**0 returns 1

Actions #2

Updated by shyouhei (Shyouhei Urabe) about 3 years ago

  • Is duplicate of Bug #13152: Numeric parsing differences between ruby <-> crystal added
  • Is duplicate of Bug #16677: Negative integer powered (**) to a float number results in a complex added
Actions

Also available in: Atom PDF

Like0
Like0Like0