Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #4290
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail |
|---|---|
| From | Jeremy Bopp <jeremy@bopp.net> |
| Newsgroups | comp.lang.ruby |
| Subject | Re: Math cube root |
| Date | Wed, 11 May 2011 15:06:40 -0500 |
| Organization | Service de news de lacave.net |
| Lines | 23 |
| Message-ID | <4DCAEC4C.6080900@bopp.net> (permalink) |
| References | <52af0ed0252adbd3445f639fbff6282f@ruby-forum.com> <dbc7278d5a23fce616550d07283c1da1@ruby-forum.com> |
| NNTP-Posting-Host | bristol.highgroove.com |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | talisker.lacave.net 1305144422 42674 65.111.164.187 (11 May 2011 20:07:02 GMT) |
| X-Complaints-To | abuse@lacave.net |
| NNTP-Posting-Date | Wed, 11 May 2011 20:07:02 +0000 (UTC) |
| In-Reply-To | <dbc7278d5a23fce616550d07283c1da1@ruby-forum.com> |
| X-Received-From | This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway |
| X-Mail-Count | 383002 |
| X-Ml-Name | ruby-talk |
| X-Rubymirror | Yes |
| X-Ruby-Talk | <4DCAEC4C.6080900@bopp.net> |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.ruby:4290 |
Show key headers only | View raw
On 5/11/2011 14:45, Sergey Avseyev wrote: > How can you explain this: > > $ irb > 1.9.2p180 (main):001:0> 1000 ** (1.0/3) > 9.999999999999998 > 1.9.2p180 (main):002:0> Math.sqrt(100) > 10.0 You're using floating point arithmetic which is always inexact. The 1.0/3 part cannot be represented with infinite precision, so it's basically rounded at a certain point. The result is then used for the rest of the operation, which may compound the inaccuracy introduced by the initial rounding. If you must use floating point operations, be prepared to accept results that are only *close* to what you expect, where close is largely dependent on the operations being performed. http://en.wikipedia.org/wiki/Floating_point -Jeremy
Back to comp.lang.ruby | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Math cube root Sergey Avseyev <sergey.avseyev@gmail.com> - 2011-05-11 14:45 -0500
Re: Math cube root Jeremy Bopp <jeremy@bopp.net> - 2011-05-11 15:06 -0500
Re: Math cube root Josef 'Jupp' Schugt <jupp@gmx.de> - 2011-05-12 07:25 -0500
Re: Math cube root serialhex <serialhex@gmail.com> - 2011-05-12 08:54 -0500
Re: Math cube root Colin Bartlett <colinb2r@googlemail.com> - 2011-05-12 10:26 -0500
Re: Math cube root Josh Cheek <josh.cheek@gmail.com> - 2011-05-12 13:30 -0500
Re: Math cube root serialhex <serialhex@gmail.com> - 2011-05-12 13:46 -0500
Re: Math cube root Rob Biedenharn <Rob@AgileConsultingLLC.com> - 2011-05-12 13:53 -0500
Re: Math cube root jzakiya <jzakiya@gmail.com> - 2011-05-12 13:20 -0700
Re: Math cube root serialhex <serialhex@gmail.com> - 2011-05-12 15:36 -0500
Re: Math cube root Martin DeMello <martindemello@gmail.com> - 2011-05-14 13:12 -0500
csiph-web