Skip to content

Commit c4af266

Browse files
committed
fix: Fix +0.0 Erlang 27 warnings. Closes #103
1 parent c43cd5b commit c4af266

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

lib/chart/scale/continuous_linear_scale.ex

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ defmodule Contex.ContinuousLinearScale do
7373
"""
7474
@spec new :: Contex.ContinuousLinearScale.t()
7575
def new() do
76-
%ContinuousLinearScale{range: {0.0, 1.0}, interval_count: 10, display_decimals: nil}
76+
%ContinuousLinearScale{range: {+0.0, 1.0}, interval_count: 10, display_decimals: nil}
7777
end
7878

7979
@doc """
@@ -132,7 +132,7 @@ defmodule Contex.ContinuousLinearScale do
132132
when is_number(min_d) and is_number(max_d) and is_number(interval_count) and
133133
interval_count > 1 do
134134
width = max_d - min_d
135-
width = if width == 0.0, do: 1.0, else: width
135+
width = if width in [-0.0, +0.0], do: 1.0, else: width
136136
unrounded_interval_size = width / interval_count
137137
order_of_magnitude = :math.ceil(:math.log10(unrounded_interval_size) - 1)
138138
power_of_ten = :math.pow(10, order_of_magnitude)
@@ -183,7 +183,10 @@ defmodule Contex.ContinuousLinearScale do
183183
0 ->
184184
fn x -> x end
185185

186-
0.0 ->
186+
+0.0 ->
187+
fn x -> x end
188+
189+
-0.0 ->
187190
fn x -> x end
188191

189192
_ ->
@@ -215,7 +218,10 @@ defmodule Contex.ContinuousLinearScale do
215218
0 ->
216219
fn x -> x end
217220

218-
0.0 ->
221+
+0.0 ->
222+
fn x -> x end
223+
224+
-0.0 ->
219225
fn x -> x end
220226

221227
_ ->

lib/chart/utils.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ defmodule Contex.Utils do
9292
def fixup_value_range({min, max}) when min == max and max > 0, do: {0, max}
9393
def fixup_value_range({min, max}) when min == max and max < 0, do: {max, 0}
9494
def fixup_value_range({0, 0}), do: {0, 1}
95-
def fixup_value_range({0.0, 0.0}), do: {0.0, 1.0}
95+
def fixup_value_range({+0.0, +0.0}), do: {+0.0, 1.0}
9696
def fixup_value_range({min, max}), do: {min, max}
9797

9898
# DateTime shifting methods copied from `defimpl Timex.Protocol, for: DateTime`

0 commit comments

Comments
 (0)