SlideShare ist ein Scribd-Unternehmen logo
1 von 38
Downloaden Sie, um offline zu lesen
The world without the
   literal notation for
   floating-point numbers


                         , Kenta Murata
   GeneticLab Co., Ltd.


Tuesday, July 19, 2011                    1
CRuby Committer
   (BigDecimal)

   Ruby Sapporo

   Kosen Conf


http://www.flickr.com/photos/koichiroo/5244581973/
Tuesday, July 19, 2011                               2
Tuesday, 1
2010 3 July 19, 2011   3
RubyKaigi
                        n   !!




Tuesday, 1
2010 3 July 19, 2011               4
Ruby    04
      Sapporo RubyKaigi 04

                         Summer 2012

Tuesday, July 19, 2011                  5
I have some question.




Tuesday, July 19, 2011                   6
Do you use Float
                             values?



Tuesday, July 19, 2011                      7
Do you understand
                     Float well?



Tuesday, July 19, 2011               8
Float is too difficult.




Tuesday, July 19, 2011                    9
Reading difficulty



Tuesday, July 19, 2011                       10
ruby-1.9.2-p290 :001 > 76287755398823936.0
   => 76287755398823940.0
  ruby-1.9.2-p290 :002 >




Tuesday, July 19, 2011                         11
Comparing difficulty



Tuesday, July 19, 2011            12
ruby-1.9.2-p290 :001 > 12.4 * 1.05 == 13.02
   => false


  ruby-1.9.2-p290 :002 > 12.4 * 1.05
   => 13.020000000000001
  ruby-1.9.2-p290 :003 >




Tuesday, July 19, 2011                          13
Representation
                           difference



Tuesday, July 19, 2011                    14
Human:	

	

 Decimal

                         Internal:	

 Binary


Tuesday, July 19, 2011                          15
Concept
                         difference



Tuesday, July 19, 2011                16
We think

                     Float is a number.


Tuesday, July 19, 2011                    17
It is real that

                         Float is a range.


Tuesday, July 19, 2011                       18
They’re troublesome



Tuesday, July 19, 2011         19
There is a solution



Tuesday, July 19, 2011                   20
Why not use Rational.



Tuesday, July 19, 2011       21
It is difficult, too.



Tuesday, July 19, 2011                          22
Ruby doesn’t have
            any literal notations
                for Rational


Tuesday, July 19, 2011              23
Does a fractional
                    notation solve the
                        problems?


Tuesday, July 19, 2011                   24
No!



Tuesday, July 19, 2011         25
We naturally use
   decimal point notation.



Tuesday, July 19, 2011       26
We need a decimal-
      point notation for
   representing a Rational.


Tuesday, July 19, 2011        27
ruby--p290 :001 > 13.02.class
   => Rational

  ruby--p290 :001 > 12.4 * 1.05 == 13.02
   => true

  ruby-1.9.2-p290 :002 > 12.4 * 1.05
   => 13.02

  ruby-1.9.2-p290 :003 > 13.02 / 3
   => (217/50)




Tuesday, July 19, 2011                     28
Do you worry about
              Rational is slow?



Tuesday, July 19, 2011            29
We can optimize for
            denominators of 10n




Tuesday, July 19, 2011            30
Float isn’t as so fast as
           you think



Tuesday, July 19, 2011          31
If you need fast Float
              calculation



Tuesday, July 19, 2011           32
Write it in C as
                         extension library



Tuesday, July 19, 2011                       33
If you need to calculate
      with arrays of Float



Tuesday, July 19, 2011        34
Use NArray



Tuesday, July 19, 2011                35
Rational may be
                         what you want



Tuesday, July 19, 2011                     36
This talk’s background,
    demonstrations, and
   more detail descriptions



Tuesday, July 19, 2011        37
Tuesday, July 19, 2011   38

Weitere ähnliche Inhalte

Ähnlich wie The world without the literal notation for floating-point numbers

Uma visão do mundo rails campus party 2011 - fabio akita
Uma visão do mundo rails   campus party 2011 - fabio akitaUma visão do mundo rails   campus party 2011 - fabio akita
Uma visão do mundo rails campus party 2011 - fabio akitaCampus Party Brasil
 
Ferramentas do mundo Rails - Campus Party 2011
Ferramentas do mundo Rails - Campus Party 2011Ferramentas do mundo Rails - Campus Party 2011
Ferramentas do mundo Rails - Campus Party 2011Fabio Akita
 
009 Society Quiz Xmas 2010
009 Society Quiz Xmas 2010009 Society Quiz Xmas 2010
009 Society Quiz Xmas 2010invercloy
 
NeedleInsights Presentation - part 2
NeedleInsights Presentation - part 2NeedleInsights Presentation - part 2
NeedleInsights Presentation - part 2sascon
 
animações e jogos além do canvas
animações e jogos além do canvasanimações e jogos além do canvas
animações e jogos além do canvasAndrews Medina
 
Apps4Academics: iPhone/iPad apps & mobile web sites for your Academic Life
Apps4Academics: iPhone/iPad apps & mobile web sites for your Academic LifeApps4Academics: iPhone/iPad apps & mobile web sites for your Academic Life
Apps4Academics: iPhone/iPad apps & mobile web sites for your Academic LifeNicole Hennig
 
2011 0419 presentation for where2
2011 0419 presentation for where22011 0419 presentation for where2
2011 0419 presentation for where2robmbailey
 
Co kodér očekává od programátora a co programátor od kodéra?
Co kodér očekává od programátora a co programátor od kodéra?Co kodér očekává od programátora a co programátor od kodéra?
Co kodér očekává od programátora a co programátor od kodéra?Martin Michálek
 
Nigeria & Designing for the Mobile Web
Nigeria & Designing for the Mobile WebNigeria & Designing for the Mobile Web
Nigeria & Designing for the Mobile WebZi Bin Cheah
 
Presentation Orange ftgroup the future of mobile
Presentation Orange ftgroup the future of mobilePresentation Orange ftgroup the future of mobile
Presentation Orange ftgroup the future of mobileVincent Everts
 
#bgeeks11 presentation draft v2
#bgeeks11 presentation draft v2#bgeeks11 presentation draft v2
#bgeeks11 presentation draft v2Rohan Gunatillake
 
NaN, Zero, & Infinities
NaN, Zero, & InfinitiesNaN, Zero, & Infinities
NaN, Zero, & InfinitiesKevin Munc
 
Conversion conference nyc-kaplan-personas-final
Conversion conference nyc-kaplan-personas-finalConversion conference nyc-kaplan-personas-final
Conversion conference nyc-kaplan-personas-finalFutureNow Inc.
 
Paper prototyping
Paper prototypingPaper prototyping
Paper prototypingErik Duval
 

Ähnlich wie The world without the literal notation for floating-point numbers (18)

Uma visão do mundo rails campus party 2011 - fabio akita
Uma visão do mundo rails   campus party 2011 - fabio akitaUma visão do mundo rails   campus party 2011 - fabio akita
Uma visão do mundo rails campus party 2011 - fabio akita
 
Ferramentas do mundo Rails - Campus Party 2011
Ferramentas do mundo Rails - Campus Party 2011Ferramentas do mundo Rails - Campus Party 2011
Ferramentas do mundo Rails - Campus Party 2011
 
Vinterminglet #SSMX
Vinterminglet #SSMXVinterminglet #SSMX
Vinterminglet #SSMX
 
009 Society Quiz Xmas 2010
009 Society Quiz Xmas 2010009 Society Quiz Xmas 2010
009 Society Quiz Xmas 2010
 
NeedleInsights Presentation - part 2
NeedleInsights Presentation - part 2NeedleInsights Presentation - part 2
NeedleInsights Presentation - part 2
 
animações e jogos além do canvas
animações e jogos além do canvasanimações e jogos além do canvas
animações e jogos além do canvas
 
Apps4Academics: iPhone/iPad apps & mobile web sites for your Academic Life
Apps4Academics: iPhone/iPad apps & mobile web sites for your Academic LifeApps4Academics: iPhone/iPad apps & mobile web sites for your Academic Life
Apps4Academics: iPhone/iPad apps & mobile web sites for your Academic Life
 
2011 0419 presentation for where2
2011 0419 presentation for where22011 0419 presentation for where2
2011 0419 presentation for where2
 
Co kodér očekává od programátora a co programátor od kodéra?
Co kodér očekává od programátora a co programátor od kodéra?Co kodér očekává od programátora a co programátor od kodéra?
Co kodér očekává od programátora a co programátor od kodéra?
 
Behind The Brandtag
Behind The BrandtagBehind The Brandtag
Behind The Brandtag
 
Nigeria & Designing for the Mobile Web
Nigeria & Designing for the Mobile WebNigeria & Designing for the Mobile Web
Nigeria & Designing for the Mobile Web
 
Presentation Orange ftgroup the future of mobile
Presentation Orange ftgroup the future of mobilePresentation Orange ftgroup the future of mobile
Presentation Orange ftgroup the future of mobile
 
#bgeeks11 presentation draft v2
#bgeeks11 presentation draft v2#bgeeks11 presentation draft v2
#bgeeks11 presentation draft v2
 
Game design 101 by Dr Malcom Ryan
Game design 101 by Dr Malcom RyanGame design 101 by Dr Malcom Ryan
Game design 101 by Dr Malcom Ryan
 
NaN, Zero, & Infinities
NaN, Zero, & InfinitiesNaN, Zero, & Infinities
NaN, Zero, & Infinities
 
Conversion conference nyc-kaplan-personas-final
Conversion conference nyc-kaplan-personas-finalConversion conference nyc-kaplan-personas-final
Conversion conference nyc-kaplan-personas-final
 
Paper prototyping
Paper prototypingPaper prototyping
Paper prototyping
 
Technobabble or Technobrilliance
Technobabble or TechnobrillianceTechnobabble or Technobrilliance
Technobabble or Technobrilliance
 

Mehr von Kenta Murata

Rubyをたのしくするために私が考えていること
Rubyをたのしくするために私が考えていることRubyをたのしくするために私が考えていること
Rubyをたのしくするために私が考えていることKenta Murata
 
Ruby の懸案事項
Ruby の懸案事項Ruby の懸案事項
Ruby の懸案事項Kenta Murata
 
5分弱で分かる量子ビット
5分弱で分かる量子ビット5分弱で分かる量子ビット
5分弱で分かる量子ビットKenta Murata
 
Rubykaigi2010mrkn bigdecimal
Rubykaigi2010mrkn bigdecimalRubykaigi2010mrkn bigdecimal
Rubykaigi2010mrkn bigdecimalKenta Murata
 
Ruby における絵文字エンコーディング間の相互変換ダイアグラム (案)
Ruby における絵文字エンコーディング間の相互変換ダイアグラム (案)Ruby における絵文字エンコーディング間の相互変換ダイアグラム (案)
Ruby における絵文字エンコーディング間の相互変換ダイアグラム (案)Kenta Murata
 
校内勉強会のススメ An encouragement to hold workshops In your school
校内勉強会のススメ An encouragement to hold workshops In your school校内勉強会のススメ An encouragement to hold workshops In your school
校内勉強会のススメ An encouragement to hold workshops In your schoolKenta Murata
 
Ruby の標準乱数生成器とその改善案
Ruby の標準乱数生成器とその改善案Ruby の標準乱数生成器とその改善案
Ruby の標準乱数生成器とその改善案Kenta Murata
 
5分で分かる Measure
5分で分かる Measure5分で分かる Measure
5分で分かる MeasureKenta Murata
 
Measure 単位付き数値ライブラリ
Measure 単位付き数値ライブラリMeasure 単位付き数値ライブラリ
Measure 単位付き数値ライブラリKenta Murata
 
情報学特論#02
情報学特論#02情報学特論#02
情報学特論#02Kenta Murata
 
情報学特論#01
情報学特論#01情報学特論#01
情報学特論#01Kenta Murata
 
北海道関数型言語勉強会@札幌#2のお知らせ
北海道関数型言語勉強会@札幌#2のお知らせ北海道関数型言語勉強会@札幌#2のお知らせ
北海道関数型言語勉強会@札幌#2のお知らせKenta Murata
 

Mehr von Kenta Murata (12)

Rubyをたのしくするために私が考えていること
Rubyをたのしくするために私が考えていることRubyをたのしくするために私が考えていること
Rubyをたのしくするために私が考えていること
 
Ruby の懸案事項
Ruby の懸案事項Ruby の懸案事項
Ruby の懸案事項
 
5分弱で分かる量子ビット
5分弱で分かる量子ビット5分弱で分かる量子ビット
5分弱で分かる量子ビット
 
Rubykaigi2010mrkn bigdecimal
Rubykaigi2010mrkn bigdecimalRubykaigi2010mrkn bigdecimal
Rubykaigi2010mrkn bigdecimal
 
Ruby における絵文字エンコーディング間の相互変換ダイアグラム (案)
Ruby における絵文字エンコーディング間の相互変換ダイアグラム (案)Ruby における絵文字エンコーディング間の相互変換ダイアグラム (案)
Ruby における絵文字エンコーディング間の相互変換ダイアグラム (案)
 
校内勉強会のススメ An encouragement to hold workshops In your school
校内勉強会のススメ An encouragement to hold workshops In your school校内勉強会のススメ An encouragement to hold workshops In your school
校内勉強会のススメ An encouragement to hold workshops In your school
 
Ruby の標準乱数生成器とその改善案
Ruby の標準乱数生成器とその改善案Ruby の標準乱数生成器とその改善案
Ruby の標準乱数生成器とその改善案
 
5分で分かる Measure
5分で分かる Measure5分で分かる Measure
5分で分かる Measure
 
Measure 単位付き数値ライブラリ
Measure 単位付き数値ライブラリMeasure 単位付き数値ライブラリ
Measure 単位付き数値ライブラリ
 
情報学特論#02
情報学特論#02情報学特論#02
情報学特論#02
 
情報学特論#01
情報学特論#01情報学特論#01
情報学特論#01
 
北海道関数型言語勉強会@札幌#2のお知らせ
北海道関数型言語勉強会@札幌#2のお知らせ北海道関数型言語勉強会@札幌#2のお知らせ
北海道関数型言語勉強会@札幌#2のお知らせ
 

Kürzlich hochgeladen

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 

Kürzlich hochgeladen (20)

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 

The world without the literal notation for floating-point numbers