Lo que todo programador debería saber sobre aritmética de punto flotante
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fixed issue #1: Added description meta header tag

+24 -3
+1
content/basic.html
··· 1 1 --- 2 2 title: Basic Answers 3 + description: Concise answers to common basic questions about floating-point math, like "Why don't my numbers add up?" 3 4 --- 4 5 5 6 ### Why don't my numbers, like 0.1 + 0.2 add up to a nice round 0.3, and instead I get a weird result like 0.30000000000000004?
+1
content/errors/comparison.html
··· 1 1 --- 2 2 title: Comparison 3 + description: Explanation of the various pitfalls in comparing floating-point numbers. 3 4 --- 4 5 5 6 Due to rounding errors, most [floating-point](/formats/fp/) numbers end up being slightly imprecise. As long as this
+1
content/errors/propagation.html
··· 1 1 --- 2 2 title: Error Propagation 3 + description: Explanations about propagation of errors in floating-point math. 3 4 --- 4 5 5 6 While the errors in single [floating-point numbers](/formats/fp/) are very small, even simple calculations on them
+1
content/errors/rounding.html
··· 1 1 --- 2 2 title: Rounding Errors 3 + description: Explanation of the reasons for rounding errors in floating-point math, and of rounding modes. 3 4 --- 4 5 5 6 Because [floating-point numbers](/formats/fp/) have a limited number of digits, they cannot represent all
+1
content/formats/binary.html
··· 1 1 --- 2 2 title: Binary Fractions 3 + description: In-depth explanation of how binary fractions work, what problems the cause and why they are used anyway 3 4 --- 4 5 5 6 How they work
+1
content/formats/exact.html
··· 1 1 --- 2 2 title: Exact Types 3 + description: Description of various datatypes that can be more exact that floating-point numbers 3 4 --- 4 5 5 6 While [binary](/formats/binary/) [floating-point](/formats/fp/) numbers are better for computers to work with, and usually good enough for humans, sometimes they are just not appropriate. Sometimes, the numbers really must add up to the last bit, and no technical excuses are acceptable - usually when the calculations involve money.
+1
content/formats/fp.html
··· 1 1 --- 2 2 title: Floating Point Numbers 3 + description: Explanation of how floating-points numbers work and what they are good for 3 4 --- 4 5 5 6 Why floating-point numbers are needed
+1
content/formats/integer.html
··· 1 1 --- 2 2 title: On Using Integers 3 + description: Explanation why using integers to avoid floating-point problems by having them represent e.g. cents is not a good solution. 3 4 --- 4 5 5 6 While integer types are usually binary and by definition do not support fractions, they are exact (no [rounding errors](/errors/rounding/) when converting from decimal integers) and can be used as a sort of "poor man's [decimal type](/formats/exact/)" by choosing an implicit fixed decimal point so that the smallest unit you work with can be represented as the integer 1. In practical terms, this is often put as: **"To handle money, store and calculate everything in cents and format only the output"**.
+2
content/index.html
··· 1 1 --- 2 2 title: What Every Programmer Should Know About Floating-Point Arithmetic 3 + description: Aims to provide both short and simple answers to the common recurring questions of novice programmers about floating-point numbers not 'adding up' correctly, and more in-depth information about how IEEE 754 floats work, when and how to use them correctly, and what to use instead when they are not appropriate. 4 + verification: SoYmbsJEmSz2s1LmZk_cku4pKwhRsU6m0ZOTgGdnTL0 3 5 --- 4 6 5 7 or
+1
content/languages/csharp.html
··· 1 1 --- 2 2 title: How to deal with floating-point numbers in C# 3 + description: Tips for using floating-point numbers in C# 3 4 --- 4 5 5 6 Floating-Point Types
+2 -1
content/languages/java.html
··· 1 1 --- 2 2 title: How to deal with floating-point numbers in Java 3 + description: Tips for using floating-point numbers in Java 3 4 --- 4 5 5 6 Floating-Point Types ··· 11 12 Decimal Types 12 13 ------------- 13 14 Java has an [arbitrary-precision](/formats/exact/) decimal type named <code>java.math.BigDecimal</code>, which 14 - also allows to choose the rounding mode: 15 + also allows to choose the rounding mode. 15 16 BigDecimal a = new BigDecimal("0.1"); 16 17 BigDecimal b = new BigDecimal("0.2"); 17 18 BigDecimal c = a.add(b); // returns a BigDecimal representing exactly 0.3
+1
content/languages/javascript.html
··· 1 1 --- 2 2 title: How to deal with floating-point numbers in JavaScript 3 + description: Tips for using floating-point numbers in JavaScript 3 4 --- 4 5 5 6 Floating-Point Types
+1
content/languages/php.html
··· 1 1 --- 2 2 title: How to deal with floating-point numbers in PHP 3 + description: Tips for using floating-point numbers in PHP 3 4 --- 4 5 5 6 Floating-Point Types
+1
content/references.html
··· 1 1 --- 2 2 title: References 3 + description: Documents with more in-depth information about floating-point math 3 4 --- 4 5 5 6 Documents that contain more in-depth information about the topics
+2 -1
content/xkcd.html
··· 1 1 --- 2 2 title: xkcd 3 + description: How to mess with people who've learned to *expect* rounding errors in floating-point math. 3 4 --- 4 5 5 6 or 6 7 -- 7 8 8 - How to mess with people who've learned to *expect* rounding errors in floating-point math. 9 + <%= @item[:description] %> 9 10 ==================== 10 11 11 12 ![Obligatory xkcd cartoon](http://imgs.xkcd.com/comics/e_to_the_pi_minus_pi.png "Obligatory xkcd cartoon")
+6 -1
layouts/default.html
··· 3 3 <head> 4 4 <meta charset="utf-8"> 5 5 <title>The Floating-Point Guide - <%= @item[:title] %></title> 6 - <meta name="google-site-verification" content="SoYmbsJEmSz2s1LmZk_cku4pKwhRsU6m0ZOTgGdnTL0" /> 6 + <% if @item[:verification] %> 7 + <meta name="google-site-verification" content="SoYmbsJEmSz2s1LmZk_cku4pKwhRsU6m0ZOTgGdnTL0" /> 8 + <% end %> 7 9 <meta name="generator" content="nanoc 3.1.2"> 10 + <% if @item[:description] %> 11 + <meta name="Description" content="<%= @item[:description] %>"> 12 + <% end %> 8 13 <link rel="stylesheet" type="text/css" href="/style.css" media="screen"> 9 14 <link rel="shortcut icon" href="/favicon.ico" type="image/vnd.microsoft.icon"> 10 15 </head>