Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
HertzDevil committed Oct 31, 2023
1 parent d4cea5f commit a915450
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
8 changes: 4 additions & 4 deletions src/big/big_float.cr
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ struct BigFloat < Float
def initialize(num : Int)
Int.primitive_si_ui_check(num) do |si, ui, big_i|
{
si: LibGMP.mpf_init_set_si(out @mpf, {{ si }}),
ui: LibGMP.mpf_init_set_ui(out @mpf, {{ ui }}),
si: LibGMP.mpf_init_set_si(out @mpf, {{ si }}),
ui: LibGMP.mpf_init_set_ui(out @mpf, {{ ui }}),
big_i: begin
LibGMP.mpf_init(out @mpf)
LibGMP.mpf_set_z(self, {{ big_i }})
Expand Down Expand Up @@ -103,8 +103,8 @@ struct BigFloat < Float
def <=>(other : Int)
Int.primitive_si_ui_check(other) do |si, ui, big_i|
{
si: LibGMP.mpf_cmp_si(self, {{ si }}),
ui: LibGMP.mpf_cmp_ui(self, {{ ui }}),
si: LibGMP.mpf_cmp_si(self, {{ si }}),
ui: LibGMP.mpf_cmp_ui(self, {{ ui }}),
big_i: self <=> {{ big_i }},
}
end
Expand Down
52 changes: 26 additions & 26 deletions src/big/big_int.cr
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ struct BigInt < Int
def <=>(other : Int)
Int.primitive_si_ui_check(other) do |si, ui, big_i|
{
si: LibGMP.cmp_si(self, {{ si }}),
ui: LibGMP.cmp_ui(self, {{ ui }}),
si: LibGMP.cmp_si(self, {{ si }}),
ui: LibGMP.cmp_ui(self, {{ ui }}),
big_i: self <=> {{ big_i }},
}
end
Expand All @@ -166,9 +166,9 @@ struct BigInt < Int
def +(other : Int) : BigInt
Int.primitive_ui_check(other) do |ui, neg_ui, big_i|
{
ui: BigInt.new { |mpz| LibGMP.add_ui(mpz, self, {{ ui }}) },
ui: BigInt.new { |mpz| LibGMP.add_ui(mpz, self, {{ ui }}) },
neg_ui: BigInt.new { |mpz| LibGMP.sub_ui(mpz, self, {{ neg_ui }}) },
big_i: self + {{ big_i }},
big_i: self + {{ big_i }},
}
end
end
Expand All @@ -184,9 +184,9 @@ struct BigInt < Int
def -(other : Int) : BigInt
Int.primitive_ui_check(other) do |ui, neg_ui, big_i|
{
ui: BigInt.new { |mpz| LibGMP.sub_ui(mpz, self, {{ ui }}) },
ui: BigInt.new { |mpz| LibGMP.sub_ui(mpz, self, {{ ui }}) },
neg_ui: BigInt.new { |mpz| LibGMP.add_ui(mpz, self, {{ neg_ui }}) },
big_i: self - {{ big_i }},
big_i: self - {{ big_i }},
}
end
end
Expand Down Expand Up @@ -219,8 +219,8 @@ struct BigInt < Int
def *(other : Int) : BigInt
Int.primitive_si_ui_check(other) do |si, ui, big_i|
{
si: BigInt.new { |mpz| LibGMP.mul_si(mpz, self, {{ si }}) },
ui: BigInt.new { |mpz| LibGMP.mul_ui(mpz, self, {{ ui }}) },
si: BigInt.new { |mpz| LibGMP.mul_si(mpz, self, {{ si }}) },
ui: BigInt.new { |mpz| LibGMP.mul_ui(mpz, self, {{ ui }}) },
big_i: self * {{ big_i }},
}
end
Expand Down Expand Up @@ -253,9 +253,9 @@ struct BigInt < Int
def unsafe_floored_div(other : Int) : BigInt
Int.primitive_ui_check(other) do |ui, neg_ui, big_i|
{
ui: BigInt.new { |mpz| LibGMP.fdiv_q_ui(mpz, self, {{ ui }}) },
ui: BigInt.new { |mpz| LibGMP.fdiv_q_ui(mpz, self, {{ ui }}) },
neg_ui: BigInt.new { |mpz| LibGMP.fdiv_q_ui(mpz, -self, {{ neg_ui }}) },
big_i: unsafe_floored_div({{ big_i }}),
big_i: unsafe_floored_div({{ big_i }}),
}
end
end
Expand All @@ -267,9 +267,9 @@ struct BigInt < Int
def unsafe_truncated_div(other : Int) : BigInt
Int.primitive_ui_check(other) do |ui, neg_ui, big_i|
{
ui: BigInt.new { |mpz| LibGMP.tdiv_q_ui(mpz, self, {{ ui }}) },
ui: BigInt.new { |mpz| LibGMP.tdiv_q_ui(mpz, self, {{ ui }}) },
neg_ui: BigInt.new { |mpz| LibGMP.tdiv_q_ui(mpz, self, {{ neg_ui }}); LibGMP.neg(mpz, mpz) },
big_i: unsafe_truncated_div({{ big_i }}),
big_i: unsafe_truncated_div({{ big_i }}),
}
end
end
Expand Down Expand Up @@ -299,9 +299,9 @@ struct BigInt < Int
def unsafe_floored_mod(other : Int) : BigInt
Int.primitive_ui_check(other) do |ui, neg_ui, big_i|
{
ui: BigInt.new { |mpz| LibGMP.fdiv_r_ui(mpz, self, {{ ui }}) },
ui: BigInt.new { |mpz| LibGMP.fdiv_r_ui(mpz, self, {{ ui }}) },
neg_ui: BigInt.new { |mpz| LibGMP.fdiv_r_ui(mpz, self, {{ neg_ui }}); LibGMP.neg(mpz, mpz) },
big_i: unsafe_floored_mod({{ big_i }}),
big_i: unsafe_floored_mod({{ big_i }}),
}
end
end
Expand All @@ -313,9 +313,9 @@ struct BigInt < Int
def unsafe_truncated_mod(other : Int) : BigInt
Int.primitive_ui_check(other) do |ui, neg_ui, big_i|
{
ui: BigInt.new { |mpz| LibGMP.tdiv_r_ui(mpz, self, {{ ui }}) },
ui: BigInt.new { |mpz| LibGMP.tdiv_r_ui(mpz, self, {{ ui }}) },
neg_ui: BigInt.new { |mpz| LibGMP.tdiv_r_ui(mpz, self, {{ neg_ui }}) },
big_i: unsafe_truncated_mod({{ big_i }}),
big_i: unsafe_truncated_mod({{ big_i }}),
}
end
end
Expand All @@ -330,9 +330,9 @@ struct BigInt < Int
the_q = BigInt.new
the_r = Int.primitive_ui_check(number) do |ui, neg_ui, big_i|
{
ui: BigInt.new { |r| LibGMP.fdiv_qr_ui(the_q, r, self, {{ ui }}) },
ui: BigInt.new { |r| LibGMP.fdiv_qr_ui(the_q, r, self, {{ ui }}) },
neg_ui: BigInt.new { |r| LibGMP.fdiv_qr_ui(the_q, r, -self, {{ neg_ui }}); LibGMP.neg(r, r) },
big_i: BigInt.new { |r| LibGMP.fdiv_qr(the_q, r, self, {{ big_i }}) },
big_i: BigInt.new { |r| LibGMP.fdiv_qr(the_q, r, self, {{ big_i }}) },
}
end
{the_q, the_r}
Expand All @@ -348,9 +348,9 @@ struct BigInt < Int
the_q = BigInt.new
the_r = Int.primitive_ui_check(number) do |ui, neg_ui, big_i|
{
ui: BigInt.new { |r| LibGMP.tdiv_qr_ui(the_q, r, self, {{ ui }}) },
ui: BigInt.new { |r| LibGMP.tdiv_qr_ui(the_q, r, self, {{ ui }}) },
neg_ui: BigInt.new { |r| LibGMP.tdiv_qr_ui(the_q, r, self, {{ neg_ui }}); LibGMP.neg(the_q, the_q) },
big_i: BigInt.new { |r| LibGMP.tdiv_qr(the_q, r, self, {{ big_i }}) },
big_i: BigInt.new { |r| LibGMP.tdiv_qr(the_q, r, self, {{ big_i }}) },
}
end
{the_q, the_r}
Expand All @@ -363,9 +363,9 @@ struct BigInt < Int
def divisible_by?(number : Int) : Bool
Int.primitive_ui_check(number) do |ui, neg_ui, big_i|
{
ui: LibGMP.divisible_ui_p(self, {{ ui }}) != 0,
ui: LibGMP.divisible_ui_p(self, {{ ui }}) != 0,
neg_ui: LibGMP.divisible_ui_p(self, {{ neg_ui }}) != 0,
big_i: divisible_by?({{ big_i }}),
big_i: divisible_by?({{ big_i }}),
}
end
end
Expand Down Expand Up @@ -453,9 +453,9 @@ struct BigInt < Int
def lcm(other : Int) : BigInt
Int.primitive_ui_check(other) do |ui, neg_ui, big_i|
{
ui: BigInt.new { |mpz| LibGMP.lcm_ui(mpz, self, {{ ui }}) },
ui: BigInt.new { |mpz| LibGMP.lcm_ui(mpz, self, {{ ui }}) },
neg_ui: BigInt.new { |mpz| LibGMP.lcm_ui(mpz, self, {{ neg_ui }}) },
big_i: lcm({{ big_i }}),
big_i: lcm({{ big_i }}),
}
end
end
Expand Down Expand Up @@ -808,9 +808,9 @@ struct Int
def -(other : BigInt) : BigInt
Int.primitive_ui_check(self) do |ui, neg_ui, big_i|
{
ui: BigInt.new { |mpz| LibGMP.neg(mpz, other); LibGMP.add_ui(mpz, mpz, {{ ui }}) },
ui: BigInt.new { |mpz| LibGMP.neg(mpz, other); LibGMP.add_ui(mpz, mpz, {{ ui }}) },
neg_ui: BigInt.new { |mpz| LibGMP.neg(mpz, other); LibGMP.sub_ui(mpz, mpz, {{ neg_ui }}) },
big_i: {{ big_i }} - other,
big_i: {{ big_i }} - other,
}
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/big/big_rational.cr
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ struct BigRational < Number
def <=>(other : Int)
Int.primitive_si_ui_check(other) do |si, ui, big_i|
{
si: LibGMP.mpq_cmp_si(self, {{ si }}, 1),
ui: LibGMP.mpq_cmp_ui(self, {{ ui }}, 1),
si: LibGMP.mpq_cmp_si(self, {{ si }}, 1),
ui: LibGMP.mpq_cmp_ui(self, {{ ui }}, 1),
big_i: self <=> {{ big_i }},
}
end
Expand Down
4 changes: 2 additions & 2 deletions src/big/number.cr
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ struct BigFloat
raise DivisionByZeroError.new if other == 0
Int.primitive_ui_check(other) do |ui, neg_ui, _|
{
ui: BigFloat.new { |mpf| LibGMP.mpf_div_ui(mpf, self, {{ ui }}) },
ui: BigFloat.new { |mpf| LibGMP.mpf_div_ui(mpf, self, {{ ui }}) },
neg_ui: BigFloat.new { |mpf| LibGMP.mpf_div_ui(mpf, self, {{ neg_ui }}); LibGMP.mpf_neg(mpf, mpf) },
big_i: BigFloat.new { |mpf| LibGMP.mpf_div(mpf, self, BigFloat.new(other)) },
big_i: BigFloat.new { |mpf| LibGMP.mpf_div(mpf, self, BigFloat.new(other)) },
}
end
end
Expand Down

0 comments on commit a915450

Please sign in to comment.