diff --git a/spec/std/complex_spec.cr b/spec/std/complex_spec.cr index 0524f912aa6d..fe0f1ac628ac 100644 --- a/spec/std/complex_spec.cr +++ b/spec/std/complex_spec.cr @@ -17,9 +17,8 @@ end describe "Complex" do describe "as numbers" do it_can_convert_between([Complex], [Complex]) - it_can_convert_between({{BUILTIN_NUMBER_TYPES_LTE_64}}, [Complex]) - it_can_convert_between([Complex], {{BUILTIN_NUMBER_TYPES_LTE_64}}) - # TODO pending conversion between Int128 + it_can_convert_between({{BUILTIN_NUMBER_TYPES}}, [Complex]) + it_can_convert_between([Complex], {{BUILTIN_NUMBER_TYPES}}) division_between_returns {{BUILTIN_NUMBER_TYPES}}, [Complex], Complex division_between_returns [Complex], {{BUILTIN_NUMBER_TYPES}}, Complex diff --git a/src/complex.cr b/src/complex.cr index d4e648e9c8fe..bbe7eb54e921 100644 --- a/src/complex.cr +++ b/src/complex.cr @@ -59,32 +59,14 @@ struct Complex @real end - # Returns the value as a `Float32` if possible (the imaginary part should be exactly zero), - # raises otherwise. - def to_f32 : Float32 - to_f64.to_f32 - end - # See `#to_f64`. def to_f to_f64 end - # Returns the value as an `Int64` if possible (the imaginary part should be exactly zero), - # raises otherwise. - def to_i64 : Int64 - to_f64.to_i64 - end - - delegate to_i32, to_i16, to_i8, to: to_i64 - - # Returns the value as an `UInt64` if possible (the imaginary part should be exactly zero), - # raises otherwise. - def to_u64 : UInt64 - to_f64.to_u64 - end - - delegate to_u32, to_u16, to_u8, to: to_u64 + delegate to_i128, to_i64, to_i32, to_i16, to_i8, to: to_f64 + delegate to_u128, to_u64, to_u32, to_u16, to_u8, to: to_f64 + delegate to_f32, to: to_f64 # See `#to_i32`. def to_i