ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:103453] [Ruby master Bug#17804] Math.cbrt(0.0) returns NaN
@ 2021-04-15  1:17 ray.chason
  2021-04-15  1:34 ` [ruby-core:103456] " xtkoba+ruby
  2021-04-28 21:36 ` [ruby-core:103647] " merch-redmine
  0 siblings, 2 replies; 3+ messages in thread
From: ray.chason @ 2021-04-15  1:17 UTC (permalink / raw)
  To: ruby-core

Issue #17804 has been reported by chasonr (Ray chason).

----------------------------------------
Bug #17804: Math.cbrt(0.0) returns NaN
https://bugs.ruby-lang.org/issues/17804

* Author: chasonr (Ray chason)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux]
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Math.cbrt(0.0) returns NaN. It should return 0.0.

From reading the implementation, I expect this bug to happen only if glibc is in use. The failing section reads:

#if defined __GLIBC__
    if (isfinite(r)) {
	r = (2.0 * r + (f / r / r)) / 3.0;
    }
#endif

and this produces a NaN when f and r are both 0.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-28 21:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-15  1:17 [ruby-core:103453] [Ruby master Bug#17804] Math.cbrt(0.0) returns NaN ray.chason
2021-04-15  1:34 ` [ruby-core:103456] " xtkoba+ruby
2021-04-28 21:36 ` [ruby-core:103647] " merch-redmine

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).