Permalink
Browse files

bigfloat: fix whitespace

  • Loading branch information...
nolta committed Sep 7, 2012
1 parent 2f2c5d1 commit b631335b174978505a5c9891e7c1f63c60679277
Showing with 88 additions and 88 deletions.
  1. +88 −88 extras/bigfloat.jl
View
@@ -3,53 +3,53 @@ _jl_libgmp_wrapper = dlopen("libgmp_wrapper")
require("bigint.jl")
type BigFloat <: FloatingPoint
- mpf::Ptr{Void}
-
- function BigFloat(x::String)
- z = _jl_BigFloat_init()
- ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_set_string), Void, (Ptr{Void}, Ptr{Uint8}), z, bytestring(x))
- b = new(z)
- finalizer(b, _jl_BigFloat_clear)
- b
- end
-
- function BigFloat(x::Float64)
- z = _jl_BigFloat_init()
- ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_set_d), Void, (Ptr{Void}, Float64), z, x)
- b = new(z)
- finalizer(b, _jl_BigFloat_clear)
- b
- end
-
- function BigFloat(x::Uint)
- z = _jl_BigFloat_init()
- ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_set_ui), Void, (Ptr{Void}, Uint), z, x)
- b = new(z)
- finalizer(b, _jl_BigFloat_clear)
- b
- end
-
- function BigFloat(x::Int)
- z = _jl_BigFloat_init()
- ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_set_si), Void, (Ptr{Void}, Int), z, x)
- b = new(z)
- finalizer(b, _jl_BigFloat_clear)
- b
- end
-
- function BigFloat(x::BigInt)
- z = _jl_BigFloat_init()
- ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_set_z), Void, (Ptr{Void}, Ptr{Void}), z, x.mpz)
- b = new(z)
- finalizer(b, _jl_BigFloat_clear)
- b
- end
-
- function BigFloat(z::Ptr{Void})
- b = new(z)
- finalizer(b, _jl_BigFloat_clear)
- b
- end
+ mpf::Ptr{Void}
+
+ function BigFloat(x::String)
+ z = _jl_BigFloat_init()
+ ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_set_string), Void, (Ptr{Void}, Ptr{Uint8}), z, bytestring(x))
+ b = new(z)
+ finalizer(b, _jl_BigFloat_clear)
+ b
+ end
+
+ function BigFloat(x::Float64)
+ z = _jl_BigFloat_init()
+ ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_set_d), Void, (Ptr{Void}, Float64), z, x)
+ b = new(z)
+ finalizer(b, _jl_BigFloat_clear)
+ b
+ end
+
+ function BigFloat(x::Uint)
+ z = _jl_BigFloat_init()
+ ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_set_ui), Void, (Ptr{Void}, Uint), z, x)
+ b = new(z)
+ finalizer(b, _jl_BigFloat_clear)
+ b
+ end
+
+ function BigFloat(x::Int)
+ z = _jl_BigFloat_init()
+ ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_set_si), Void, (Ptr{Void}, Int), z, x)
+ b = new(z)
+ finalizer(b, _jl_BigFloat_clear)
+ b
+ end
+
+ function BigFloat(x::BigInt)
+ z = _jl_BigFloat_init()
+ ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_set_z), Void, (Ptr{Void}, Ptr{Void}), z, x.mpz)
+ b = new(z)
+ finalizer(b, _jl_BigFloat_clear)
+ b
+ end
+
+ function BigFloat(z::Ptr{Void})
+ b = new(z)
+ finalizer(b, _jl_BigFloat_clear)
+ b
+ end
end
convert(::Type{BigFloat}, x::Int8) = BigFloat(int(x))
@@ -78,71 +78,71 @@ promote_rule(::Type{BigFloat}, ::Type{Uint16}) = BigFloat
promote_rule(::Type{BigFloat}, ::Type{Uint32}) = BigFloat
promote_rule(::Type{BigFloat}, ::Type{Uint64}) = BigFloat
-function +(x::BigFloat, y::BigFloat)
- z= _jl_BigFloat_init()
- ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_add), Void, (Ptr{Void}, Ptr{Void}, Ptr{Void}), z, x.mpf, y.mpf)
- BigFloat(z)
+function +(x::BigFloat, y::BigFloat)
+ z= _jl_BigFloat_init()
+ ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_add), Void, (Ptr{Void}, Ptr{Void}, Ptr{Void}), z, x.mpf, y.mpf)
+ BigFloat(z)
end
-function -(x::BigFloat)
- z= _jl_BigFloat_init()
- ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_neg), Void, (Ptr{Void}, Ptr{Void}), z, x.mpf)
- BigFloat(z)
+function -(x::BigFloat)
+ z= _jl_BigFloat_init()
+ ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_neg), Void, (Ptr{Void}, Ptr{Void}), z, x.mpf)
+ BigFloat(z)
end
function -(x::BigFloat, y::BigFloat)
- z= _jl_BigFloat_init()
- ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_sub), Void, (Ptr{Void}, Ptr{Void}, Ptr{Void}), z, x.mpf, y.mpf)
- BigFloat(z)
+ z= _jl_BigFloat_init()
+ ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_sub), Void, (Ptr{Void}, Ptr{Void}, Ptr{Void}), z, x.mpf, y.mpf)
+ BigFloat(z)
end
-function *(x::BigFloat, y::BigFloat)
- z= _jl_BigFloat_init()
- ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_mul), Void, (Ptr{Void}, Ptr{Void}, Ptr{Void}), z, x.mpf, y.mpf)
- BigFloat(z)
+function *(x::BigFloat, y::BigFloat)
+ z= _jl_BigFloat_init()
+ ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_mul), Void, (Ptr{Void}, Ptr{Void}, Ptr{Void}), z, x.mpf, y.mpf)
+ BigFloat(z)
end
function /(x::BigFloat, y::BigFloat)
- z= _jl_BigFloat_init()
- ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_div), Void, (Ptr{Void}, Ptr{Void}, Ptr{Void}), z, x.mpf, y.mpf)
- BigFloat(z)
+ z= _jl_BigFloat_init()
+ ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_div), Void, (Ptr{Void}, Ptr{Void}, Ptr{Void}), z, x.mpf, y.mpf)
+ BigFloat(z)
end
-function cmp(x::BigFloat, y::BigFloat)
- ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_cmp), Int32, (Ptr{Void}, Ptr{Void}), x.mpf, y.mpf)
+function cmp(x::BigFloat, y::BigFloat)
+ ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_cmp), Int32, (Ptr{Void}, Ptr{Void}), x.mpf, y.mpf)
end
function sqrt(x::BigFloat)
- z = _jl_BigFloat_init()
- ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_sqrt), Void, (Ptr{Void}, Ptr{Void}), z, x.mpf)
- BigFloat(z)
+ z = _jl_BigFloat_init()
+ ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_sqrt), Void, (Ptr{Void}, Ptr{Void}), z, x.mpf)
+ BigFloat(z)
end
-function pow(x::BigFloat, y::Uint)
- z = _jl_BigFloat_init()
- ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_pow_ui), Void, (Ptr{Void}, Ptr{Void}, Uint), z, x.mpf, y)
+function pow(x::BigFloat, y::Uint)
+ z = _jl_BigFloat_init()
+ ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_pow_ui), Void, (Ptr{Void}, Ptr{Void}, Uint), z, x.mpf, y)
BigFloat(z)
end
-==(x::BigFloat, y::BigFloat) = cmp(x,y) == 0
-<=(x::BigFloat, y::BigFloat) = cmp(x,y) <= 0
->=(x::BigFloat, y::BigFloat) = cmp(x,y) >= 0
-<(x::BigFloat, y::BigFloat) = cmp(x,y) < 0
->(x::BigFloat, y::BigFloat) = cmp(x,y) > 0
-
-function string(x::BigFloat)
- s=ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_printf), Ptr{Uint8}, (Ptr{Void},), x.mpf)
- ret = bytestring(s) #This copies s.
- c_free(s)
- ret
+==(x::BigFloat, y::BigFloat) = cmp(x,y) == 0
+<=(x::BigFloat, y::BigFloat) = cmp(x,y) <= 0
+>=(x::BigFloat, y::BigFloat) = cmp(x,y) >= 0
+<(x::BigFloat, y::BigFloat) = cmp(x,y) < 0
+>(x::BigFloat, y::BigFloat) = cmp(x,y) > 0
+
+function string(x::BigFloat)
+ s=ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_printf), Ptr{Uint8}, (Ptr{Void},), x.mpf)
+ ret = bytestring(s) #This copies s.
+ c_free(s)
+ ret
end
show(io, b::BigFloat) = print(io, string(b))
-function _jl_BigFloat_clear(x::BigFloat)
- ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_clear), Void, (Ptr{Void},), x.mpf)
+function _jl_BigFloat_clear(x::BigFloat)
+ ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_clear), Void, (Ptr{Void},), x.mpf)
end
-function _jl_BigFloat_init()
- return ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_init), Ptr{Void}, ())
+function _jl_BigFloat_init()
+ return ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpf_init), Ptr{Void}, ())
end

0 comments on commit b631335

Please sign in to comment.