Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #3613

Re: float precision

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail
From Brian Candler <b.candler@pobox.com>
Newsgroups comp.lang.ruby
Subject Re: float precision
Date Thu, 28 Apr 2011 03:04:18 -0500
Organization Service de news de lacave.net
Lines 22
Message-ID <6a573846f8c628a3ba44998931503b96@ruby-forum.com> (permalink)
References <d8523ab0be463b71c967051445fc92ca@ruby-forum.com> <227e84a0-24ff-4984-a93e-98d40f53aac1@d1g2000hsg.googlegroups.com> <Hbzyk.36400$Mh5.1689@bgtnsc04-news.ops.worldnet.att.net> <b7499cfe-f5a8-4245-9504-970bdccb0148@i76g2000hsf.googlegroups.com> <9e3fd2c80809160355r323f6beeqd953d5ccfb06758c@mail.gmail.com> <4fa64434d7ba9283414f65a68d0837e9@ruby-forum.com> <d8b1a7254598249b0ae543fb5672545e@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 1303977873 90666 65.111.164.187 (28 Apr 2011 08:04:33 GMT)
X-Complaints-To abuse@lacave.net
NNTP-Posting-Date Thu, 28 Apr 2011 08:04:33 +0000 (UTC)
In-Reply-To <d8b1a7254598249b0ae543fb5672545e@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 382291
X-Ml-Name ruby-talk
X-Rubymirror Yes
X-Ruby-Talk <6a573846f8c628a3ba44998931503b96@ruby-forum.com>
Xref x330-a1.tempe.blueboxinc.net comp.lang.ruby:3613

Show key headers only | View raw


Joshua S. wrote in post #995421:
> Not surprisingly, it's extremely quicker to convert to a string and
> match a regular expression.
>
>       user     system      total        real
> spf  :  1.560000   0.000000   1.560000 (  1.557252)
> *100 :  0.320000   0.000000   0.320000 (  0.322573)
> *.01 :  0.350000   0.000000   0.350000 (  0.343289)
> regex:  0.000000   0.000000   0.000000 (  0.000019)

You should be suspicious of a result which indicates it's 5 orders of 
magnitude faster.

>   r.report('regex:') {
>     f4 = float.to_s.match(/(^-?\d+(\.\d{1,2})?)/)[1].to_f
>   }

Ahem, you forgot the "times.times do...end" loop in the benchmark :-)

-- 
Posted via http://www.ruby-forum.com/.

Back to comp.lang.ruby | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: float precision "Joshua S." <joshsuggs@gmail.com> - 2011-04-27 17:32 -0500
  Re: float precision Brian Candler <b.candler@pobox.com> - 2011-04-28 03:04 -0500
    Re: float precision "Joshua S." <joshsuggs@gmail.com> - 2011-04-28 12:37 -0500

csiph-web