Permalink
Browse files

add DomainError for ilogb of zero or NaN

add significand()
  • Loading branch information...
1 parent a3a9e9f commit 5c1c5045bafa9f70e93312b369c49450231ba47d @JeffBezanson JeffBezanson committed Jul 27, 2012
Showing with 16 additions and 2 deletions.
  1. +15 −1 base/math_libm.jl
  2. +1 −1 base/sysimg.jl
View
16 base/math_libm.jl
@@ -71,7 +71,21 @@ end
#@_jl_libmfunc_1arg_int Real lrint
#@_jl_libmfunc_1arg_int Real lround iround
-@_jl_libmfunc_1arg_int Real ilogb
+function ilogb(x::Float64)
+ if x==0 || isnan(x)
+ throw(DomainError())
+ end
+ ccall(dlsym(_jl_libm,:ilogb), Int32, (Float64,), x)
+end
+function ilogb(x::Float32)
+ if x==0 || isnan(x)
+ throw(DomainError())
+ end
+ ccall(dlsym(_jl_libm,:ilogbf), Int32, (Float32,), x)
+end
+@vectorize_1arg Real ilogb
+
+@_jl_libmfunc_1arg_float Real significand
@_jl_libfdmfunc_2arg Number atan2
atan2(x::Real, y::Real) = atan2(float64(x), float64(y))
View
2 base/sysimg.jl
@@ -167,7 +167,7 @@ export
rotl90,rotr90,round,rpad,rr2id,rref,rstrip,run,safe_char,scan,search,
searchsorted,sec,secd,sech,seek,select,select!,select_read,serialize,
setenv,setfield,setsuccess,shift,show,showall,showcompact,shuffle,shuffle!,
- sign,signbit,signed,similar,sin,sinc,sind,sinh,size,sizeof,skip,
+ sign,signbit,signed,significand,similar,sin,sinc,sind,sinh,size,sizeof,skip,
sleep,slice,slicedim,sort,sort!,sort_by,sort_by!,sortperm,sortr,sortr!,
spawn,spawnat,spawnlocal,split,sprint,sprintf,sqrt,square,squeeze,srand,
sshow,start,std,stderr,stderr_stream,stdin,stdin_stream,stdout,

0 comments on commit 5c1c504

Please sign in to comment.