Commit Graph
5550 Commits
Author SHA1 Message Date
José Valim c19ed9f910 Introduce Float.ratio/1 and fix Float.{ceil/2, floor/2, round/2}
The previous implementations for ceil, floor and round were
not formalized and were likely prone to multiple roundings
as we performed multiplication and division by a power of
10 on the given float.

The new implementation correctly converts the float to an
exact integer representation and perform all operations using
arbitrary precision integers. The only float operation occurs
when converting the ratio back to a float.

The current implementation is more expensive due to its reliance
on big integers. Faster implementations are available in literature
where the latest one seems to be Errol:

  https://cseweb.ucsd.edu/~lerner/papers/fp-printing-popl16.pdf

This change also introduces Float.ratio/1 which receives a
float and returns a pair of integers whose ratio is exactly equal
to the original float and with a positive denominator.

Closes #3400
2016-10-07 18:46:33 +02:00
Myron Marston 3a4b8bf4da Improve Task.yield/2 docs to suggest Task.shutdown/1. (#5292)
As discussed on the mailing list:

https://groups.google.com/forum/#!topic/elixir-lang-core/0uaxTaVN-bw
2016-10-07 11:33:53 +01:00
Aleksei Magusev c16f54c6ad Use fully qualified call in in_range_literal/3 helper 2016-10-07 01:29:20 +02:00
Aleksei Magusev 819a11256a Improve in_range/3 helper indentation in Kernel 2016-10-07 01:29:20 +02:00
Aleksei Magusev 9d67a0262b Expand in/2 test samples only once 2016-10-07 01:29:20 +02:00
Aleksei Magusev 7a0986eb26 Extract in/2 with range literals handling to its own function 2016-10-07 01:29:20 +02:00
Josh Branchaud 986f45d775 Add an example of Regex.scan/3 using unicode (#5294) 2016-10-07 00:58:27 +02:00
Ben Olive 181450530a Implement Stream.zip/1 and Enum.zip/1 (#5289) 2016-10-04 16:12:07 +02:00
José Valim d8adc34e68 Add a TODO to variable warnings 2016-10-04 14:19:25 +02:00
Magnus Lång 8bd6c17a6b Fix Dialyzer warnings on opaque protocol calls (#5286)
Prior to this change, calling a protocol function with an opaque type
would yield a warning, as Dialyzer concludes that the impl_for/1
function can't handle opaque arguments, since all clauses would
destructure their arguments in some way.

By adding a catch-all clause that does not destructure its argument,
Dialyzer no longer draws this conclusion, and the warnings go away.

As noted in the protocol.ex comment, this is technically a hack as it
relies on Dialyzer not being smart enough. However, I would not expect
it to break soon, if ever.
2016-10-04 14:17:11 +02:00
Charles Renwick 5c5e624e06 Fixes a silly typo in the docs (#5269) 2016-10-04 09:34:22 +02:00
Eksperimental af070d4244 Use underscore after "my" word in code samples (#5284) 2016-10-02 19:58:54 +02:00
José Valim 949e629f68 Handle pid/port from other nodes explicitly and talk about ports on errors 2016-10-02 09:31:35 +02:00
James Fish 16f73ab50d Ignore bad type errors for Process.register/2 2016-10-01 21:49:30 +01:00
Ville Hellman (FxN) 465b1f1721 More helpful error message when Process.register/2 fails (#5281) 2016-10-01 21:46:01 +01:00
José Valim a82c594ba4 Add @moduledoc false to GenEvent.Stream 2016-09-30 12:31:44 +02:00
José Valim 611799b0a5 Use sub headers instead of a big list 2016-09-30 08:56:55 +02:00
James Fish 82cd54bcae Log error on unhandled GenServer message by default (#5250) 2016-09-29 21:30:18 +01:00
Michał Muskała 5054a26145 Fix Macro.to_string when printing keywords (#5270)
It was incorrect when given a literal atom resembling an alias.

Fixes #5268
2016-09-29 10:48:01 +02:00
José Valim 3a343bb122 Improve summaries for any/all 2016-09-28 14:53:45 +02:00
Aleksei Magusev 8eae1166fd Consider is_process_alive/1 calls in returns_boolean/1 check 2016-09-28 13:19:26 +02:00
Aleksei Magusev 79a72ae26c Consider is_record/1,2,3 calls in returns_boolean/1 check 2016-09-28 13:08:45 +02:00
Aleksei Magusev 4e681d5fcb Consider is_map/1 calls in returns_boolean/1 check 2016-09-28 12:49:49 +02:00
José Valim 89adb42b58 Update return boolean check for orelse/andalso 2016-09-28 10:30:48 +02:00
José Valim 819d81c28e Do not build matches if variables are the same 2016-09-27 18:24:34 +02:00
José Valim 93ca080bb9 Move raise checks to runtime callback, closes #5257 2016-09-26 20:36:15 +02:00
James Fish 662ecf9be7 Fix Task.shutdown/1,2 infinite block when no monitor (#5252)
If the monitor no longer exists Task.shutdown/2 would block forever
waiting for it. Always setup new monitor and try to get the right down
result.
2016-09-25 19:13:44 +01:00
Aleksei Magusev 25e51bb498 Add extra test for string concatenation as match usage
This case has been fixed in 78c7ddc03f.
2016-09-25 01:44:20 +02:00
Benjamin Tan Wei Hao 43e8f2e6e5 exit(child, :kill) -> Process.exit(child, :kill) (#5245)
Because consistency! <3
2016-09-23 09:48:44 +03:00
Alexei Sholik cf8f7c96a2 Use singular names for time units, as in Erlang/OTP 19.1. Fix #5236 (#5244) 2016-09-22 23:28:13 +03:00
Ivan Kozik 21c35e89e5 Fix precision note in the "Operators" reference page (#5243) 2016-09-22 15:42:03 +02:00
Eksperimental 50a6b8722b Fix a typo in the "Operators" page of the docs (#5242) 2016-09-22 10:25:20 +02:00
Aleksei Magusev 8962160465 Use Unix time wording 2016-09-21 23:57:03 +02:00
Aleksei Magusev fdf1348fcb Simplify Calendar.ISO.last_day_of_month/2 definition 2016-09-21 23:41:00 +02:00
Aleksei Magusev 9cd972dbde Remove unnecessary whitespaces in "colors" test for IO.ANSI 2016-09-21 23:41:00 +02:00
José Valim 8e2a1e5851 Remove Kernel.rand/0 and Kernel.rand/1
Since Enum.random/1 already provides the Kernel.rand/1
functionality.
2016-09-21 23:39:33 +02:00
Frédéric Boyer 06083a995f Clarify some of the subtleties linked to term ordering in the docs (#5238) 2016-09-21 23:07:01 +02:00
Dorian Karter a3e96ee241 Add documentation: Enum.random accepting ranges (#5237)
Also mentions that ranges are not traversed and therefore run in
constant time and constant memory.

Based on
https://hashrocket.com/blog/posts/the-adventures-of-generating-random-numbers-in-erlang-and-elixir
2016-09-21 21:46:57 +02:00
James Fish 357bb4f914 Update dialyzer tests for OTP-19.1/dialyzer-3.0.2 2016-09-21 15:31:46 +01:00
Andrea Leopardi dd78780363 Fix a few typos introduced in 904e89782d 2016-09-21 11:11:16 +02:00
Steven Blowers 904e89782d Fixing spelling mistakes of specially -> especially. (#5235) 2016-09-21 10:27:34 +02:00
Andrea Leopardi 9da967d909 Add a section about comparison operators in the "Operators" page (#5230) 2016-09-20 13:02:35 +02:00
ToadJamb 2cd5506fba Add light foreground and background colors to IO.ANSI (#5231) 2016-09-20 11:09:24 +02:00
Aleksei Magusev 742cb73097 Tidy up Enum.concat/1,2 tests 2016-09-20 00:57:54 +02:00
Andrea Leopardi 9796d1684f Make the docs for Task.Supervisor slightly more clear
This could improve situations like the one happened in #5225.
2016-09-19 22:42:50 +02:00
Vitalii Elenhaupt 810965e193 Extended test suite for Enum.concat/2 (#5229) 2016-09-19 11:32:28 +02:00
Jose Añasco 762e7de8ad Fix typo in Calendar moduledoc (#5227) 2016-09-19 08:47:13 +02:00
José Valim c05151f278 Update CHANGELOG 2016-09-17 22:40:54 +02:00
Aleksei Magusev e6971f966c Return given value value in Module.put_attribute/3 (#5218) 2016-09-15 11:12:02 +02:00
José Valim b6360b0aae Fix last_day_of_month callback 2016-09-15 10:28:56 +02:00