Giter Site home page Giter Site logo

0.30000000000000004's People

Contributors

0racle avatar abrudz avatar aconchillo avatar amirtcho avatar anirbanmu avatar ash avatar autarch avatar bjsemrad avatar blieque avatar brackendev avatar braincompiler avatar brehberg avatar cncolder avatar cowens avatar dependabot[bot] avatar dkordic avatar envek avatar erikwiffin avatar ihid avatar ircmaxell avatar itaisteinherz avatar lazymofo avatar lengau avatar linuxbckp avatar polymeris avatar sixlettervariables avatar sre42 avatar stefanedwards avatar still-learning avatar vendethiel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

0.30000000000000004's Issues

add equality test

I would recommend adding another test that shows whether

0.1+0.2==0.3

in the various languages. One or two will get it right, but most do not, even the ones that print 0.3 when you do the addition.

erlang examples

1> io:format("~f~n", [0.1 + 0.2]). 
0.300000
ok
2> io:format("~e~n", [0.1 + 0.2]).
3.00000e-1

objective-c gone

objective-c gone from the list of languages on website after updating examples.

Note on GHC

Using Double triggers the Problem in GHC, Float works fine (could be a precision reason, though):

Prelude> 0.2 + 0.1 :: Double
0.30000000000000004
Prelude> 0.2 + 0.1 :: Float 
0.3

Enforce HTTPS

Hi there, GitHub has an option to redirect the traffic from HTTP to HTTPS, it's in the project settings under the GitHub Pages section

image

image

Project description and link

The link at the end of the README could be added to the repository metadata fields at the top of the page, where it would be more accessible.

A description can also be added there, which would appear in the page title in browser tabs, in search results, etc.

Add GNU Octave Code and Results

The results are partially different with which in Matlab.

File:


layout: post
title: 'GNU Octave'
code:

  • 0.1 + 0.2
  • single(0.1)+single(0.2)
  • double(0.1)+double(0.2)
  • 0.1+single(0.2)
  • 0.1+double(0.2)
  • "sprintf('%.17f',0.1+0.2)"
    result:
  • 0.30000
  • 0.30000
  • 0.30000
  • 0.30000
  • 0.30000
  • 0.30000000000000004

Additionally, I met an error-403 while "git push". Could you give me the push permission?

The PHP example wrongly suggests PHP acts properly

Your echo .1 + .2; displays 0.3 because PHP converts it to a string in echo first while still internally using 0.30000000000000004. You can verify this with: echo ceil((.1 + .2) * 10); (this prints 4). My suggestion is to run a similar test for all languages and displaying and (if needed) explaining the results.

Clojure improvements

;; Bigdecimal support
(+ 0.1M 0.2M)
; => 0.3

;; Ratios
(+ 1/10 2/10)
;=> 3/10

DAX example

There are not that many examples of this in Data Analysis Expressions (DAX),

It would be:

EVALUATE { VAR _sum = 0.1 + 0.2 // 0.30000000000000004 RETURN IF( _sum = 0.3, ":)", ":(" ) }

EVALUATE { VAR _sum = CURRENCY( 0.1 ) + CURRENCY( 0.2 ) // 0.3 RETURN IF( _sum = 0.3, ":)", ":(" ) }

Raku output is truncated

Although the markdown source for Raku shows the correct output to raku -e 'say (0.1 + 0.2).fmt("%.17f")' is 0.30000000000000000, on the published website just shows the output as 0.3.

Allowed to Mirror?

Hey Erik Wiffin. Thanks for your initiative to build this site. Very helpful to introduce people about floating point.

Yet, the main site: http://0.30000000000000004.com/ seems down right now so i can't refer people to this site. Currently, there is no way to access this website other than from GH repo and archive.is. Could i mirror this? I don't see LICENSE file so i ask about this.

Also related to #105

Some more database info

A bug I filed about IEEE 754 documentation a while ago for MySQL:
https://bugs.mysql.com/bug.php?id=57519

Support for NaN differs between MySQL and PostgreSQL. I didn't see any information about the 'special' values on http://0.30000000000000004.com

Note that there are different behaviors within one database system:
http://sqlfiddle.com/#!6/12e70/3

CREATE TABLE t1 (f FLOAT);
SELECT 0.1 + 0.2;
INSERT INTO t1 VALUES(0.1),(0.2);
SELECT SUM(f) FROM t1;

With Microsoft SQL Server 2014 this has the following output:

0.3
0.30000000000000004

With MySQL 5.6:

0.3
0.30000000447034836

http://sqlfiddle.com/#!9/2e75e/1

Oracle 11gR2 returns 0.3 in both cases:
http://sqlfiddle.com/#!4/0509e6/4

Note that Oracle has FLOAT and BINARY_FLOAT
http://sqlfiddle.com/#!4/cf223/1

awk example is deceptive

$ awk --version | head -1
GNU Awk 5.1.1, API: 3.1 (GNU MPFR 4.1.0-p13, GNU MP 6.2.1)

The example indeed prints 0.3, but 0.1 + 0.2 != 0.3:

$ awk 'BEGIN { print 0.1 + 0.2 }'
0.3
$ awk 'BEGIN { print (0.1 + 0.2) == 0.3 }'
0

It's because

$ awk 'BEGIN { printf "%0.25f", 0.1 + 0.2 }'
0.3000000000000000444089210
$ awk 'BEGIN { printf "%0.25f", 0.3 }'
0.2999999999999999888977698

MYSQL FLOAT

Perhaps this example could explain.

CREATE TABLE test(fla FLOAT,flb FLOAT,dba DOUBLE(10,2),dbb DOUBLE(10,2));
We have a table like this:

+-------+-------------+
| Field | Type |
+-------+-------------+
| fla | float |
| flb | float |
| dba | double(10,2)|
| dbb | double(10,2)|
+-------+-------------+
For first difference, we try to insert a record with '1.2' to each field:

INSERT INTO test values (1.2,1.2,1.2,1.2);
The table showing like this:

SELECT * FROM test;

+------+------+------+------+
| fla | flb | dba | dbb |
+------+------+------+------+
| 1.2 | 1.2 | 1.20 | 1.20 |
+------+------+------+------+
See the difference?

We try to next example:

SELECT fla+flb, dba+dbb FROM test;
Hola! We can find the difference like this:

+--------------------+---------+
| fla+flb | dba+dbb |
+--------------------+---------+
| 2.4000000953674316 | 2.40 |
+--------------------+---------+

Source: https://stackoverflow.com/a/28511784/676479

[C++] setprecision() uses the std namespace

The C++ example is as follows:

std::cout << setprecision(17) << 0.1 + 0.2 << std.endl;

The function setprecision() uses the std namespace, and should therefore be written as such. Same goes for endl. Furthermore, the C example also works in C++; perhaps these should be merged?

Link to published website

Is this repo published somewhere? It would be a good idea to include a link to the published website in this repos README.md

Font size is too small

12px is much too small. I recommend leaving it at the default (normally 16px), and defining most other things in terms of ems or rems instead of pixels, and using max-width: 100% so that the greater width isn’t causing overflow trouble unnecessarily. (Mostly you could instead change widths to max-widths, but some bits may need to be told to be as wide as possible within that.)

Use of the word `decimals` is confusing

Use of the word decimals is confusing. For example:

In binary, 1 / 2, 1 / 4, 1 / 8 would all be expressed cleanly as decimals, while 1 / 5 or 1 / 10 would be repeating decimals

Here the first-use as decimals is correct, meaning when converted to decimal and written out, but the second-use is confusing; I think it means "digits after the binary-point". I don't think "decimals" is a good word to mean "digits after the binary-point".

I don't have a better word, just found it confusing. Please let me know if I got it all wrong. Awesome explanation though - love it :)

Proposal: move this to gh-pages

You could leverage gh-pages build to host this site and it would work with custom domain as well.
Or you could just push to gh-pages branch an have http://erikwiffin.github.io/0.30000000000000004 server as backup mirror.
If you consider switching to gh-pages with domain name, you can find instruction

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.