aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gleam/float.gleam14
-rw-r--r--test/gleam/float_test.gleam62
-rw-r--r--test/gleam/int_test.gleam8
3 files changed, 42 insertions, 42 deletions
diff --git a/src/gleam/float.gleam b/src/gleam/float.gleam
index d9ce292..dd6adee 100644
--- a/src/gleam/float.gleam
+++ b/src/gleam/float.gleam
@@ -289,9 +289,9 @@ if javascript {
/// ```
///
pub fn absolute_value(x: Float) -> Float {
- case x >=. 0. {
+ case x >=. 0.0 {
True -> x
- _ -> 0. -. x
+ _ -> 0.0 -. x
}
}
@@ -326,14 +326,14 @@ pub fn absolute_value(x: Float) -> Float {
/// ```
///
pub fn power(base: Float, of exponent: Float) -> Result(Float, Nil) {
- let fractional: Bool = ceiling(exponent) -. exponent >. 0.
+ let fractional: Bool = ceiling(exponent) -. exponent >. 0.0
// In the following check:
// 1. If the base is negative and the exponent is fractional then
// return an error as it will otherwise be an imaginary number
// 2. If the base is 0 and the exponent is negative then the expression
// is equivalent to the exponent divided by 0 and an error should be
// returned
- case base <. 0. && fractional || base == 0. && exponent <. 0. {
+ case base <. 0.0 && fractional || base == 0.0 && exponent <. 0.0 {
True -> Error(Nil)
False -> Ok(do_power(base, exponent))
}
@@ -377,7 +377,7 @@ pub fn square_root(x: Float) -> Result(Float, Nil) {
/// ```
///
pub fn negate(x: Float) -> Float {
- -1. *. x
+ -1.0 *. x
}
/// Sums a list of `Float`s.
@@ -412,8 +412,8 @@ fn do_sum(numbers: List(Float), initial: Float) -> Float {
///
pub fn product(numbers: List(Float)) -> Float {
case numbers {
- [] -> 0.
- _ -> do_product(numbers, 1.)
+ [] -> 0.0
+ _ -> do_product(numbers, 1.0)
}
}
diff --git a/test/gleam/float_test.gleam b/test/gleam/float_test.gleam
index a068647..e8ebe6a 100644
--- a/test/gleam/float_test.gleam
+++ b/test/gleam/float_test.gleam
@@ -61,27 +61,27 @@ pub fn clamp_test() {
}
pub fn compare_test() {
- float.compare(0., 0.)
+ float.compare(0.0, 0.0)
|> should.equal(order.Eq)
float.compare(0.1, 0.1)
|> should.equal(order.Eq)
- float.compare(0., 0.1)
+ float.compare(0.0, 0.1)
|> should.equal(order.Lt)
- float.compare(-2., -1.9)
+ float.compare(-2.0, -1.9)
|> should.equal(order.Lt)
- float.compare(2., 1.9)
+ float.compare(2.0, 1.9)
|> should.equal(order.Gt)
- float.compare(-1.9, -2.)
+ float.compare(-1.9, -2.0)
|> should.equal(order.Gt)
}
pub fn loosely_compare_test() {
- float.loosely_compare(10.2, 10.5, tolerating: 0.)
+ float.loosely_compare(10.2, 10.5, tolerating: 0.0)
|> should.equal(order.Lt)
float.loosely_compare(10.2, with: 10.5, tolerating: 0.31)
@@ -101,7 +101,7 @@ pub fn loosely_compare_test() {
}
pub fn loosely_equals_test() {
- float.loosely_equals(10.2, 10.5, tolerating: 0.)
+ float.loosely_equals(10.2, 10.5, tolerating: 0.0)
|> should.be_false
float.loosely_equals(10.2, with: 10.5, tolerating: 0.31)
@@ -201,14 +201,14 @@ pub fn truncate_test() {
}
pub fn min_test() {
- float.min(0., 0.)
- |> should.equal(0.)
+ float.min(0.0, 0.0)
+ |> should.equal(0.0)
float.min(0.3, 1.5)
|> should.equal(0.3)
- float.min(1., 0.)
- |> should.equal(0.)
+ float.min(1.0, 0.0)
+ |> should.equal(0.0)
float.min(-1.7, 2.5)
|> should.equal(-1.7)
@@ -216,22 +216,22 @@ pub fn min_test() {
float.min(-2.2, -2.2)
|> should.equal(-2.2)
- float.min(-1., -1.)
- |> should.equal(-1.)
+ float.min(-1.0, -1.0)
+ |> should.equal(-1.0)
- float.min(-1.1, -1.)
+ float.min(-1.1, -1.0)
|> should.equal(-1.1)
}
pub fn max_test() {
- float.max(0., 0.)
- |> should.equal(0.)
+ float.max(0.0, 0.0)
+ |> should.equal(0.0)
float.max(0.3, 1.5)
|> should.equal(1.5)
- float.max(1., 0.)
- |> should.equal(1.)
+ float.max(1.0, 0.0)
+ |> should.equal(1.0)
float.max(-1.7, 2.5)
|> should.equal(2.5)
@@ -239,11 +239,11 @@ pub fn max_test() {
float.max(-2.2, -2.2)
|> should.equal(-2.2)
- float.max(-1., -1.)
- |> should.equal(-1.)
+ float.max(-1.0, -1.0)
+ |> should.equal(-1.0)
- float.max(-1.1, -1.)
- |> should.equal(-1.)
+ float.max(-1.1, -1.0)
+ |> should.equal(-1.0)
}
pub fn absolute_value_test() {
@@ -318,14 +318,14 @@ pub fn square_root_test() {
}
pub fn negate_test() {
- float.negate(-1.)
- |> should.equal(1.)
+ float.negate(-1.0)
+ |> should.equal(1.0)
- float.negate(2.)
- |> should.equal(-2.)
+ float.negate(2.0)
+ |> should.equal(-2.0)
- float.negate(0.)
- |> should.equal(0.)
+ float.negate(0.0)
+ |> should.equal(0.0)
}
pub fn sum_test() {
@@ -338,10 +338,10 @@ pub fn sum_test() {
pub fn product_test() {
float.product([])
- |> should.equal(0.)
+ |> should.equal(0.0)
- float.product([4.])
- |> should.equal(4.)
+ float.product([4.0])
+ |> should.equal(4.0)
float.product([2.5, 3.2, 4.2])
|> should.equal(33.6)
diff --git a/test/gleam/int_test.gleam b/test/gleam/int_test.gleam
index 4768432..851013d 100644
--- a/test/gleam/int_test.gleam
+++ b/test/gleam/int_test.gleam
@@ -137,16 +137,16 @@ pub fn to_base36_test() {
pub fn to_float_test() {
int.to_float(1)
- |> should.equal(1.)
+ |> should.equal(1.0)
int.to_float(5)
- |> should.equal(5.)
+ |> should.equal(5.0)
int.to_float(0)
- |> should.equal(0.)
+ |> should.equal(0.0)
int.to_float(-5)
- |> should.equal(-5.)
+ |> should.equal(-5.0)
}
pub fn compare_test() {