Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- c1 = Decimal.div(a1, b1)
- # => #Decimal<0.006453859622556080696687234694>
- iex> alias Decimal, as: D
- nil
- iex> d = D.div(D.new(1), D.new(3))
- #Decimal<0.3333333333333333333333333333>
- iex> D.round(d, 5)
- #Decimal<0.33333>
- iex> D.set_context(%D.Context{D.get_context | precision: 5})
- :ok
- iex> a = D.div(D.new(100.12345), D.new(3))
- #Decimal<33.374>
- iex> D.set_context(%D.Context{D.get_context | precision: 5})
- :ok
- iex> a = D.div(D.new(1), D.new(3))
- #Decimal<0.33333>
- iex> b = D.new("0.006453859622556080696687234694")
- #Decimal<0.006453859622556080696687234694>
- iex> D.add(a,b)
- #Decimal<0.33978>
- rounded_c1 = Decimal.round(c1, 4)
- ceil_c1 = Decimal.round(c1, 4, :ceiling)
- floor_c1 = Decimal.round(c1, 4, :floor)
Add Comment
Please, Sign In to add comment