Skip to content

Commit

Permalink
Align examples according to inspect protocol (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
vshev4enko authored Apr 29, 2023
1 parent 12f2776 commit 31999e3
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ interactive Elixir shell with `iex -S mix`:
```elixir
iex> alias Decimal, as: D
iex> D.add(6, 7)
#Decimal<13>
Decimal.new("13")
iex> D.div(1, 3)
#Decimal<0.333333333>
Decimal.new("0.3333333333333333333333333333")
iex> D.new("0.33")
#Decimal<0.33>
Decimal.new("0.33")
```

## Examples
Expand Down Expand Up @@ -87,13 +87,13 @@ iex> D.Context.set(%D.Context{D.Context.get() | precision: 9})
:ok

iex> D.div(100, 3)
#Decimal<33.3333333>
Decimal.new("33.3333333")

iex> D.Context.set(%D.Context{D.Context.get() | precision: 2})
:ok

iex> D.div(100, 3)
#Decimal<33>
Decimal.new("33")
```

The `:rounding` option specifies the algorithm and precision of the rounding
Expand All @@ -104,13 +104,13 @@ iex> D.Context.set(%D.Context{D.Context.get() | rounding: :half_up})
:ok

iex> D.div(31, 2)
#Decimal<16>
Decimal.new("16")

iex> D.Context.set(%D.Context{D.Context.get() | rounding: :floor})
:ok

iex> D.div(31, 2)
#Decimal<15>
Decimal.new("15")
```

### Comparisons
Expand Down Expand Up @@ -148,7 +148,7 @@ iex> D.Context.get().flags
[]

iex> D.div(31, 2)
#Decimal<15>
Decimal.new("15")

iex> D.Context.get().flags
[:inexact, :rounded]
Expand Down Expand Up @@ -180,7 +180,7 @@ iex> D.Context.set(%D.Context{D.Context.get() | traps: [], flags: []})
:ok

iex> D.div(42, 0)
#Decimal<Infinity>
Decimal.new("Infinity")

iex> D.Context.get().flags
[:division_by_zero]
Expand Down

0 comments on commit 31999e3

Please sign in to comment.