Your SlideShare is downloading. ×
Perlで任意精度計算
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Perlで任意精度計算

1,980
views

Published on

YAPC::Asia Tokyo 2010 presentation

YAPC::Asia Tokyo 2010 presentation

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,980
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide





















































  • Transcript

    • 1. 3.14159 26535 89793 23846 26433 83279 50288.....
    • 2. use Math::BigFloat; my $x = Math::BigFloat->new(‘3.1415...’); my $y = Math::BigFloat->new(‘2.718281...’); my $z = $x * $y;
    • 3. # my $pi = Math::BigFloat->new(3.141592...); # my $pi = Math::BigFloat->new(‘3.141592...’);
    • 4. use strict; use Math::BigFloat; use Benchmark qw(cmpthese); cmpthese -1, {     plain => sub {         my $x = rand(10);         my $y = rand(10);         my $z = rand(10);         ($x + $y ) * $z;     },     bigfloat => sub {         my $x = rand(10);         my $y = rand(10);         my $z = rand(10);         (Math::BigFloat->new($x) + Math::BigFloat->new($y)) * Math::BigFloat->new($z);     }, };
    • 5. daisuke@beefcake ~$ perl foo.pl               Rate bigfloat plain bigfloat 3380/s -- -100% plain 2383127/s 70403% -- daisuke@beefcake ~$ perl foo.pl               Rate bigfloat plain bigfloat 3380/s -- -100% plain 2360644/s 69738% -- daisuke@beefcake ~$ perl foo.pl               Rate bigfloat plain bigfloat 3380/s -- -100% plain 2406041/s 71081% --
    • 6. > perl benchmark.pl Rate bigfloat plain bigfloat 3901/s -- -100% plain 2338582/s 59849% --
    • 7. •DateTime::Util::Calc •DateTime::Util::Astro •DateTime::Event::Lunar
    • 8. my $v = ( $x + $y ) * $z; #include <mpfr.h> mpfr_t x, y, z, w; mpfr_add( w, x, y, MPFR_RNDN ); mpfr_mul( w, w, z, MPFR_RNDN );
    • 9. mpfr_add( w, x, y, MPFR_RNDN );
    • 10. s/iter bigint xs bigint 2.58 -- -98% mpfr 4.70e-02 5394% --

    ×